AI-2020/raport.md

98 lines
2.2 KiB
Markdown
Raw Normal View History

2020-05-11 15:58:47 +02:00
# Podprojekt Szi
### Opis
2020-05-18 14:50:27 +02:00
Tematem podprojektu jest rozpoznawanie zamówień na podstawie historii zamówień.
Użyłem drzew decyzyjnych.
2020-05-11 15:58:47 +02:00
### Dane
2020-05-18 14:50:27 +02:00
Potrawy, ich nazwa, rodzaj oraz charakterystyka.
2020-05-11 15:58:47 +02:00
2020-05-11 16:14:53 +02:00
2020-05-11 15:58:47 +02:00
menu = Context.fromstring(''' |meat|salad|meal|drink|cold|hot |
2020-05-18 14:50:27 +02:00
Pork | X | | | | | X |
2020-05-11 15:58:47 +02:00
Espresso | | | | X | | X |
2020-05-18 14:50:27 +02:00
Latte | | | | X | | X |
2020-05-11 15:58:47 +02:00
Green Tea | | | | X | X | |
2020-05-18 14:50:27 +02:00
Greek Salad| | X | | | X | |
2020-05-11 15:58:47 +02:00
Pizza | | | X | | | X |''')
2020-05-18 14:50:27 +02:00
Dane uczące:
2020-05-18 16:38:44 +02:00
2020-05-18 14:50:27 +02:00
training_data = [
['meat','hot','Pork'],
['salad','cold','Greek Salad'],
['drink','hot','Espresso'],
['drink','hot','Latte'],
['drink','cold','Green Tea'],
['meal','hot','Pizza'],
2020-05-18 16:38:44 +02:00
['meal','cold','Wheat Pita'],
2020-05-18 14:50:27 +02:00
]
2020-05-11 15:58:47 +02:00
2020-05-18 16:38:44 +02:00
Dane testowe jest tworzone losowo w funkcji:
def client_ordering():
order = []
2020-05-11 16:13:58 +02:00
2020-05-18 16:38:44 +02:00
dish = uniq_val_from_data(training_data, 0)
temperature = uniq_val_from_data(training_data, 1)
2020-05-11 16:13:58 +02:00
2020-05-18 16:38:44 +02:00
tmpr = random.sample(dish, 1)
order.append(tmpr[0])
2020-05-11 15:58:47 +02:00
2020-05-18 16:38:44 +02:00
tmpr = random.sample(temperature, 1)
order.append(tmpr[0])
order.append('order')
return order
2020-05-11 16:13:58 +02:00
2020-05-11 15:58:47 +02:00
2020-05-11 16:14:53 +02:00
2020-05-18 16:38:44 +02:00
### Implementacja
####Drzewo:
Klasy:
#####Question
class Queestion:
def __init__(self, col, value):
self.col = col #column
self.value = value #value of column
def compare(self, example):
#compare val in example with val in the question
def __repr__(self):
#just to print
#####Node
class Decision_Node():
#contain the question and child nodes
def __init__(self, quest, t_branch, f_branch):
self.quest = quest
self.t_branch = t_branch
self.f_branch = f_branch
#####Leaf
class Leaf:
#contain a number of how many times the label has appeared in dataset
def __init__(self, rows):
self.predicts = uniq_count(rows)
2020-05-11 16:24:34 +02:00
2020-05-11 15:58:47 +02:00
### Biblioteki
* concepts
* random
* numpy