This commit is contained in:
Piotr Jakub Dębski 2020-06-15 14:10:43 +02:00
parent 36b7544a1b
commit 1231a8f914
8 changed files with 499 additions and 1 deletions

73
Customertree.md Normal file
View File

@ -0,0 +1,73 @@
Piotr Jakub Dębski 01.06.2020
## Automatyczny kelner: raport podprojektu indywidualnego
W tym dokumencie opisane zostały podstawy i najważniejsze informacje dotyczące powstania
oraz funkcjonowania podprojektu indywidualnego.
### Cel projektu
Celem projektu jest dodanie do projektu Zautomatyzowanego Kelnera sztucznej inteligencji u
klientów restauracji, która na podstawie kilku przypisanych do obiektu klienta cech pozwoli mu
na samodzielne wybranie zamówionego dania oraz napoju. Osobny moduł będzie miał za zadanie
stworzyć modele drzewa decyzyjnego, które będą używane w głownym pliku projektu.
### Biblioteki
Do wykonania projektu wykorzystane zostały następujące biblioteki Pythona:
- random
- joblib
- pandas
- sklearn
- pydot
oraz dodatkowo:
- graphviz
za pomocą którego wygenerowane została reprezentacja wizualna drzew decyzyjnych
food_tree.pdf oraz drink_tree.pdf znajdujących się w folderze graphs.
### Dane
Dane na których podstawie algorytm ma stworzyć modele drzew decyzyjnych umieszczone zostały w
pliku learning_db.py i podzielone na 6 binarnych kategorii:
- gender - płeć ( M - mężczyzna K - kobieta )
- age - wiek ( Adult - dorosły Child - dziecko )
- outfit - ubiór ( Casual - codzienny Elegant - reprezentacyjny )
- cash - pieniądze ( "+" - dużo "-" - mało )
- vege - dieta wegetariańska ( "Yes" "No" )
- time - czas ( "Afternoon" - popołudnie "Evening" - wieczór )
oraz na 2 kategorie, które mają zostać sklasyfikowane :
- food - dania ( 35 wyborów )
- drink - napoje ( 8 wyborów )
Dane zawierają 200 przykładów.
### Tworzenie drzewa
1. Za pomocą funkcji pandas.DataFrame() program łączy ze sobą wszystkie przykłady w
dwuwymiarową strukturę danych o wymiarach 9x200 (kategorie+index)x(przykłady).
2. Za pomocą funkcji pandas.factorize() program dostosowuje dane w każdej kolumnie do naszych
potrzeb i obliczeń.
3. Następnie model danych zostaje podzielony na X - zbiór przykładów oraz y - odpowiadający
przykładom wynik czyli rodzaj dania.
4. Zestaw danych zostaje podzielony na testowy dzięki funkcji train_test_split()
( 25% - food , 40% - drink) i treningowy ( 75% - food , 60% - drink )
5. Dzięki funkcji DecisionTreeClassifier() oraz tą samą funkcją z argumentem wymagającym przyjęcia
do kryterium entropii tworzą się dwa klasyfikatory (wyniki będą porównywane by wybrać
dokładniejszą metodę)
6. Zestaw treningowy przekazany zostaje do funkcji fit() dzięki czemu można teraz
przeprowadzić predykcję za pomocą funkcji predict(), której w miejsce argumentu wprowadzamy
zestaw testowy.
7. W wyniku wielokrotnych porównań dokładności funkcji predict() na klasyfikatorach, entropia
okazuje się lepszym kryterium od indeksu Giniego na zadanym zestawie danych, więc model drzewa
korzystający z tego kryterium zostaje zapisany do użycia w głównym ciele projektu.
8. Kroki 3-7 zostały powtórzone dla drzewa napojów, a odpowiednie wizualizacje drzew decyzyjnych
zapisane są w folderze graphs.
### Synchronizacja w projekcie
Modele food_model i drink_model zostaną załadowane do programu z folderu models.
Do obsługi stworzonego modelu stworzona jest klasa Client oraz funkcja client_ordering(ctr)
Klasa Client poprzez swój konstruktor automatycznie losuje wszystkie cechy, na podstawie
których funkcja predict() wybiera danie oraz napój, natomiast funkcja client_ordering(ctr) wymaga
w swoim argumencie posiadania obiektu klasy Client, z której pobierze wszystkie wartości cech
i przeniesie je do funkcji predict() zwracając otrzymane wyniki.

105
customertree.py Normal file
View File

@ -0,0 +1,105 @@
import pandas as pandas
import graphviz
import pydot
from learning_db import *
from joblib import dump
from sklearn import tree
from sklearn.metrics import accuracy_score
from sklearn.externals.six import StringIO
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
customers = pandas.DataFrame({"gender": gender,
"age": age,
"outfit": outfit,
"cash": cash,
"time": time,
"vege": vege,
"food": food,
"drink": drink
})
customers["gender"], gender_objects = pandas.factorize(customers["gender"])
customers["age"], age_objects = pandas.factorize(customers["age"])
customers["outfit"], outfit_objects = pandas.factorize(customers["outfit"])
customers["cash"], cash_objects = pandas.factorize(customers["cash"])
customers["time"], time_objects = pandas.factorize(customers["time"])
customers["vege"], vege_objects = pandas.factorize(customers["vege"])
customers["food"], food_objects = pandas.factorize(customers["food"])
customers["drink"], drink_objects = pandas.factorize(customers["drink"])
objects = []
objects.append(gender_objects)
objects.append(age_objects)
objects.append(outfit_objects)
objects.append(cash_objects)
objects.append(time_objects)
objects.append(vege_objects)
objects.append(food_objects)
objects.append(drink_objects)
#X = customers.drop(["food","drink"], axis=1)
#y = customers["food"]
#X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=None)
#food_classifier = DecisionTreeClassifier(criterion = "entropy", random_state=1)
#food_classifier.fit(X_train, y_train)
#porównanie kryterium: index Giniego i entropia
#food_classifier1 = DecisionTreeClassifier()
#food_classifier1.fit(X_train, y_train)
#food_classifier2 = DecisionTreeClassifier(criterion = "entropy")
#food_classifier2.fit(X_train, y_train)
#y_pred1 = food_classifier1.predict(X_test)
#y_pred2 = food_classifier2.predict(X_test)
#if accuracy_score(y_test, y_pred1) > accuracy_score(y_test, y_pred2):
# dump(food_classifier,'models/food_model.joblib')
#else:
# dump(food_classifier2,'models/food_model.joblib')
#dot_data=StringIO()
#tree = tree.export_graphviz(food_classifier, out_file = dot_data,
# feature_names = X.columns,
# class_names = food_objects,
# filled = True, rounded = True)
#graph = pydot.graph_from_dot_data(dot_data.getvalue())
#graph[0].write_pdf("graphs/food_model.pdf")
#X = customers.drop(["food","drink"], axis=1)
#y = customers["drink"]
#X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.45, random_state=1)
#drink_classifier = DecisionTreeClassifier(criterion = "entropy")
#drink_classifier.fit(X_train, y_train)
#drink_classifier1 = DecisionTreeClassifier()
#drink_classifier1.fit(X_train, y_train)
#drink_classifier2 = DecisionTreeClassifier(criterion = "entropy")
#drink_classifier2.fit(X_train, y_train)
#y_pred1 = drink_classifier1.predict(X_test)
#y_pred2 = drink_classifier2.predict(X_test)
#if accuracy_score(y_test, y_pred1) > accuracy_score(y_test, y_pred2):
# dump(drink_classifier1,'models/drink_model.joblib')
#else:
# dump(drink_classifier2,'models/drink_model.joblib')
#dot_data=StringIO()
#tree = tree.export_graphviz(drink_classifier, out_file = dot_data,
# feature_names = X.columns,
# class_names = drink_objects,
# filled = True, rounded = True)
#graph = pydot.graph_from_dot_data(dot_data.getvalue())
#graph[0].write_pdf("graphs/drink_model.pdf")

BIN
graphs/drink_model.pdf Normal file

Binary file not shown.

BIN
graphs/food_model.pdf Normal file

Binary file not shown.

235
learning_db.py Normal file
View File

@ -0,0 +1,235 @@
gender = ["M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"M","M","M","M","M","M","M","M","M","M",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W",
"W","W","W","W","W","W","W","W","W","W"
]
age = ["Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Child","Child","Child","Child","Child","Child","Child","Child","Child","Child",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult","Adult",
"Child","Child","Child","Child","Child","Child","Child","Child","Child","Child"
]
outfit = ["Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant",
"Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant",
"Casual","Casual","Casual","Casual","Casual","Elegant","Elegant","Elegant","Elegant","Elegant",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual","Casual",
"Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant",
"Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant","Elegant",
"Casual","Casual","Casual","Casual","Casual","Elegant","Elegant","Elegant","Elegant","Elegant"
]
cash = ["+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"-","+","-","+","-","+","-","+","-","+",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-",
"-","-","-","-","-","-","-","-","-","-",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"+","+","+","+","+","+","+","+","+","+",
"-","+","-","+","-","+","-","+","-","+"
]
time = ["Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Evening","Evening","Afternoon","Afternoon","Evening","Evening","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon","Afternoon",
"Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening","Evening",
"Afternoon","Afternoon","Evening","Evening","Afternoon","Afternoon","Evening","Evening","Afternoon","Afternoon"
]
vege = ["No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","Yes","Yes",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","No","No",
"No","No","No","No","No","Yes","Yes","Yes","Yes","Yes",
"No","No","No","No","No","No","No","No","Yes","Yes"
]
food = ['club_sandwich','steak','hot_dog','hamburger','hot_dog',
'hot_dog','hot_dog','club_sandwich','steak','club_sandwich',
'hamburger','steak','hamburger','club_sandwich','hot_dog',
'hot_dog','steak','hot_dog','apple_pie','ice_cream',
'pizza','hot_dog','hamburger','steak','club_sandwich',
'ice_cream','waffles','greek_salad','greek_salad','greek_salad',
'lasagna','lasagna','ice_cream','ice_cream','steak',
'greek_salad','waffles','greek_salad','apple_pie','waffles',
'hamburger','pizza','lasagna','hamburger','hamburger',
'ice_cream','waffles','greek_salad','club_sandwich','ice_cream',
'pizza','ice_cream','pizza','greek_salad','ice_cream',
'lasagna','pizza','pizza','hamburger','club_sandwich',
'club_sandwich','pizza','club_sandwich','apple_pie','club_sandwich',
'ice_cream','waffles','greek_salad','apple_pie','greek_salad',
'club_sandwich','steak','pizza','hamburger','hot_dog',
'hamburger','steak','hot_dog','steak','hot_dog',
'hot_dog','hot_dog','hamburger','steak','club_sandwich',
'greek_salad','waffles','waffles','apple_pie','greek_salad',
'club_sandwich','club_sandwich','pizza','waffles','apple_pie',
'hot_dog','ice_cream','greek_salad','apple_pie','ice_cream',
'club_sandwich','steak','steak','hamburger','hot_dog',
'hot_dog','hot_dog','club_sandwich','steak','club_sandwich',
'hamburger','steak','steak','lasagna','hot_dog',
'hot_dog','ice_cream','greek_salad','pizza','ice_cream',
'hot_dog','hot_dog','hamburger','steak','club_sandwich',
'waffles','waffles','greek_salad','waffles','greek_salad',
'lasagna','lasagna','lasagna','lasagna','lasagna',
'ice_cream','waffles','waffles','apple_pie','greek_salad',
'pizza','pizza','hamburger','hamburger','ice_cream',
'ice_cream','waffles','greek_salad','apple_pie','ice_cream',
'lasagna','ice_cream','hamburger','hamburger','ice_cream',
'hamburger','hamburger','pizza','pizza','ice_cream',
'lasagna','hot_dog','hamburger','steak','club_sandwich',
'ice_cream','waffles','greek_salad','apple_pie','ice_cream',
'club_sandwich','steak','hot_dog','hamburger','hot_dog',
'hamburger','steak','hot_dog','hamburger','hot_dog',
'hot_dog','steak','hamburger','steak','club_sandwich',
'ice_cream','waffles','greek_salad','apple_pie','greek_salad',
'ice_cream','ice_cream','lasagna','apple_pie','apple_pie',
'hot_dog','ice_cream','hot_dog','apple_pie','waffles'
]
drink = ["Whisky","Whisky","Whisky","Whisky","Whisky",
"Whisky","Whisky","Beer","Beer","Beer",
"Cola","Water","Orange Juice","Water","Beer",
"Cola","Water","Orange Juice","Cola","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Cola","Water","Orange Juice","Water","Beer",
"Cola","Water","Orange Juice","Cola","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Cola","Water","Orange Juice","Water","Beer",
"Cola","Water","Orange Juice","Cola","Beer",
"Whisky","Whisky","Whisky","Whisky","Whisky",
"Whisky","Whisky","Whisky","Beer","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Cola","Water","Orange Juice","Water","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Beer","Beer","Beer","Beer","Beer",
"Orange Juice","Orange Juice","Cola","Cola","Cola",
"Cola","Cola","Cola","Cola","Cola",
"Whisky","Whisky","Whisky","Red Wine","Red Wine",
"Red Wine","Red Wine","Red Wine","Red Wine","Whisky",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Whisky","Whisky","Whisky","Red Wine","Red Wine",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Red Wine","Red Wine","Whisky","Whisky","Whisky",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Water","Water","Orange Juice","Orange Juice","Cola",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Red Wine","Red Wine","Red Wine","Red Wine","Red Wine",
"Orange Juice","Orange Juice","Orange Juice","Orange Juice","Orange Juice",
"Orange Juice","Orange Juice","Orange Juice","Cola","Cola"
]

87
main.py
View File

@ -10,6 +10,9 @@ import numpy as np
from data import *
from choice_tree import *
from joblib import load
from customertree import objects
import tensorflow as tf
from keras import *
import h5py
@ -36,6 +39,9 @@ CATEGORIES = [
"waffles"
]
food_model = load("models/food_model.joblib")
drink_model = load("models/drink_model.joblib")
model = tf.keras.models.load_model('final1')
with h5py.File('food_10_64x3_test.hdf5', "r") as f:
@ -104,6 +110,84 @@ def client_ordering():
###
class Client:
def __init__(self):
self.gender = random.choice(["Man","Woman"])
self.outfit = random.choice(["Casual","Elegant"])
self.cash = random.choice([20,20,20,30,30,50,50,70,80,90,100,100,120,
120,150,200,300,500])
self.time = random.choice(["Afternoon","Evening"])
self.vege = random.choice(["No","No","No","No","Yes"])
self.age = random.randint(12,80)
def __str__(self):
return (self.gender + " Age: " + str(self.age) +" "+ self.outfit+
" $"+ str(self.cash)+ " Vege: "+ self.vege)
def order_drink(clt):
frame = []
if clt.gender == "Man":
frame.append(0)
else:
frame.append(1)
if clt.age > 17:
frame.append(0)
else:
frame.append(1)
if clt.outfit == "Casual":
frame.append(0)
else:
frame.append(1)
if clt.cash > 100:
frame.append(0)
else:
frame.append(1)
if clt.time == "Evening":
frame.append(0)
else:
frame.append(1)
if clt.vege == "No":
frame.append(0)
else:
frame.append(1)
drink_predict = drink_model.predict([frame])
drink_index = drink_predict[0]
return objects[-1][drink_index]
def order_food(clt):
frame = []
if clt.gender == "Man":
frame.append(0)
else:
frame.append(1)
if clt.age > 17:
frame.append(0)
else:
frame.append(1)
if clt.outfit == "Casual":
frame.append(0)
else:
frame.append(1)
if clt.cash > 100:
frame.append(0)
else:
frame.append(1)
if clt.time == "Evening":
frame.append(0)
else:
frame.append(1)
if clt.vege == "No":
frame.append(0)
else:
frame.append(1)
food_predict = food_model.predict([frame])
food_index = food_predict[0]
return objects[-2][food_index]
###
class Node:
def __init__(self, state, parent, action):
@ -553,7 +637,8 @@ while True:
restaurant.tiles[waiter.y][waiter.x].clientState = "wait"
waiter.orders = (waiter.x, waiter.y)
DEFINE += 1
waiter.order_list.insert(0, random.choice(CATEGORIES))
cl = Client()
waiter.order_list.insert(0,client_ordering_food(cl))
if (waiter.x, waiter.y) == KITCHEN:
if waiter.orders:
restaurant.kitchen.append([waiter.orders[0], waiter.orders[1], 50])

BIN
models/drink_model.joblib Normal file

Binary file not shown.

BIN
models/food_model.joblib Normal file

Binary file not shown.