This commit is contained in:
Serhii Hromov 2020-05-18 14:38:44 +00:00
parent 9455e783a4
commit 3c8dc84f7b

View File

@ -23,6 +23,7 @@ Potrawy, ich nazwa, rodzaj oraz charakterystyka.
Dane uczące: Dane uczące:
training_data = [ training_data = [
['meat','hot','Pork'], ['meat','hot','Pork'],
['salad','cold','Greek Salad'], ['salad','cold','Greek Salad'],
@ -30,30 +31,62 @@ Dane uczące:
['drink','hot','Latte'], ['drink','hot','Latte'],
['drink','cold','Green Tea'], ['drink','cold','Green Tea'],
['meal','hot','Pizza'], ['meal','hot','Pizza'],
['meal','cold','Wheat Pita'],
] ]
Dane testowe: Dane testowe jest tworzone losowo w funkcji:
test_data = [
['meat','hot','Latte'], def client_ordering():
['salad','hot','Greek Salad'], order = []
['drink','hot','Pork'],
['drink','cold','Green Tea'], dish = uniq_val_from_data(training_data, 0)
['drink','hot','Greek Salad'], temperature = uniq_val_from_data(training_data, 1)
]
tmpr = random.sample(dish, 1)
order.append(tmpr[0])
tmpr = random.sample(temperature, 1)
order.append(tmpr[0])
order.append('order')
return order
### Implementacja ### Implementacja
Główna część: ####Drzewo:
In process 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)
### Biblioteki ### Biblioteki