1
0

Compare commits

..

7 Commits

Author SHA1 Message Date
1960ef885d final_evaluation 2020-06-15 09:15:22 +00:00
b0914a076c final_evaluation_v2 2020-06-15 08:40:36 +00:00
soybby
47f6311d71 f 2020-06-15 00:36:53 +02:00
soybby
c8afe48b63 additional help s444519 2020-05-18 12:04:32 +02:00
soybby
b006b5b7b7 project s444519 2020-05-18 12:01:38 +02:00
soybby
adc584e542 csv s444529 2020-05-18 11:58:08 +02:00
soybby
32bb6289d1 csv file #3 s444519 2020-05-18 11:18:40 +02:00
5 changed files with 1679 additions and 0 deletions

354
AI_projecty.py Normal file
View File

@ -0,0 +1,354 @@
import pandas as pd
import pygame
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from pygame.locals import *
import numpy as np
import matplotlib.pyplot as plt
from sklearn import tree
import random
from textpygame import get_key, ask, display_box
#read csv file
dataset= pd.read_csv("veganism.csv")
#show shape of dataset
print(dataset.shape)
#create a new dataset
newdataset = pd.DataFrame(dataset, columns=['ethnicity', 'gender', 'appearence', 'vegan'])
# creating instance of labelencoder
labelencoder = LabelEncoder()
# Assigning numerical values and storing in another column
newdataset['ethnicity_no'] = labelencoder.fit_transform(newdataset['ethnicity'])
newdataset['gender_no']= labelencoder.fit_transform(newdataset['gender'])
newdataset['appearence_no']= labelencoder.fit_transform(newdataset['appearence'])
print(newdataset)
# for x values drop unimportant columns, axis=1 specifies that we want the columns not rows
Y=newdataset['vegan']
X=newdataset.drop(newdataset.columns[0:4], axis=1)
print(X,Y)
#test 14% of the data
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.15)
classifier = DecisionTreeClassifier()
classifier.fit(X_train, Y_train)
y_pred = classifier.predict(X_test)
#ignores minority groups which results in 0 for prediction. to solve this i have to use smthing else
print(pd.DataFrame(confusion_matrix(Y_test, y_pred),columns=['Predicted not vegan', 'Predicted vegan'], index=['Actually not vegan', 'Actually vegan']))
#accuracy score is high as expected
print(accuracy_score(Y_test, y_pred))
fn=['ethnicity','gender','appearence']
cn=['yes', 'no']
# Setting dpi = 300 to make image clearer than default
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (4,4), dpi=300)
tree.plot_tree(classifier,
feature_names = fn,
class_names=cn,
filled = True);
fig.savefig('imagenamenew.png')
#using the my_grid3 program
# Colors:
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 240)
MAGENTA=(255, 0, 255)
# Width and Height of each square:
WIDTH = 20
HEIGHT = 20
# Margin:
MARGIN = 5
grid = [[0 for x in range(16)] for y in range(16)]
def change_value(i, j, width, n):
for r in range(i, i + width):
for c in range(j, j + width):
grid[r][c] = n
if grid[r][c]==5:
break
class Table:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j, 2, 1)
class Kitchen:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j, 3, 2)
class Agent:
def __init__(self, orig_coordinate_i, orig_coordinate_j):
self.orig_coordinate_i = orig_coordinate_i
self.orig_coordinate_j = orig_coordinate_j
self.state = np.array([1, 2])
change_value(orig_coordinate_j, orig_coordinate_j, 1, 3)
self.state_update(orig_coordinate_i, orig_coordinate_j)
def state_update(self, c1, c2):
self.state[0] = c1
self.state[1] = c2
print(self.state)
def leave(self):
change_value(self.state[0], self.state[1], 1, 0)
def move_up(self):
self.leave()
self.state_update(x - 1, y)
change_value(self.state[0], self.state[1], 1, 3)
def move_down(self):
self.leave()
change_value(self.state[0], self.state[1], 1, 0)
self.state_update(x + 1, y)
change_value(self.state[0], self.state[1], 1, 3)
def move_right(self):
self.leave()
self.state_update(x, y + 1)
change_value(self.state[0], self.state[1], 1, 3)
def move_left(self):
self.leave()
self.state_update(x, y - 1)
change_value(self.state[0], self.state[1], 1, 3)
class Customer:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j,1 , 4)
class CustomerPlace:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j,1 , 5)
## default positions of the agent:
x = 11
y = 11
agent = Agent(x, y)
table1 = Table(2, 2)
table2 = Table(2, 7)
table3 = Table(2, 12)
table4 = Table(7, 2)
table5 = Table(7, 7)
table6 = Table(7, 12)
table7 = Table(12, 2)
table8 = Table(12, 7)
pygame.init()
# create a font object.
# 1st parameter is the font file
# which is present in pygame.
# 2nd parameter is size of the font
font = pygame.font.Font('freesansbold.ttf', 14)
X = 400
Y = 400
# create a text suface object,
# on which text is drawn on it.
text = font.render('waiter: hello, let me help you with your order.', True, WHITE, BLACK)
userText=font.render('user: ', True, BLUE, BLACK)
# create a rectangular object for the
# text surface object
textRect = text.get_rect()
inputRect = userText.get_rect()
# set the center of the rectangular object.
textRect.center= (200, 340)
inputRect.center=(200,370)
# class Kitchen:
kitchen = Kitchen(13, 13)
x=[2,7,12]
y=[2,7]
random_customer_seat_x=random.choice(x)
random_customer_seat_y=random.choice(y)
print(random_customer_seat_x,random_customer_seat_y)
seat=Customer(random_customer_seat_x,random_customer_seat_y)
next_to=CustomerPlace(random_customer_seat_x,random_customer_seat_y-1)
WINDOW_SIZE = [405, 405]
screen = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("Waiter_Grid3")
done = False
print(random_customer_seat_x,random_customer_seat_y-1)
clock = pygame.time.Clock()
#updating the drawing
def updateDraw():
x = agent.state[0]
y = agent.state[1]
screen.fill(BLACK) # Background color
for row in range(16): # Drawing the grid
for column in range(16):
color = WHITE
if grid[row][column] == 1:
color = GREEN
if grid[row][column] == 2:
color = RED
if grid[row][column] == 3:
color = BLUE
if grid[row][column] == 4:
color = MAGENTA
surface = pygame.draw.rect(screen,
color,
[(MARGIN + WIDTH) * column + MARGIN,
(MARGIN + HEIGHT) * row + MARGIN,
WIDTH,
HEIGHT])
def customer():
if x == random_customer_seat_x and y == random_customer_seat_y - 1:
screen.blit(text, textRect)
ethnicity3= ask(screen, question="ethnicity ")
gender3= ask(screen,question="gender ")
appearence3=ask(screen, question="appearence ")
if ethnicity3 == "black":
ethnicity3 = 1
elif ethnicity3 == "asian":
ethnicity3 = 0
else:
ethnicity3 = 2
if gender3 == "male":
gender3 = 0
else:
gender3 = 1
if appearence3 == "hippie":
appearence3= 0
else:
appearence3 = 1
prediction = classifier.predict([[ethnicity3, gender3, appearence3]])
pygame.quit()
if prediction == [0]:
print("You're probably not vegan. Would you like a regular menu?")
else:
print("It seems like youre vegan. Would you like a vegan menu?")
exit()
running=True
# pick a font you have and set its size
text2 = 'this text is editable'
font2 = pygame.font.SysFont(None, 48)
img2 = font.render(text2, True, RED)
rect2 = img2.get_rect()
rect2.topleft = (20, 20)
background = BLACK
# put the label object on the screen at point x=100, y=100
cursor = Rect(rect2.topright, (3, rect2.height))
while running:
x = agent.state[0]
y = agent.state[1]
pygame.time.delay(100)
for event in pygame.event.get(): # Checking for the event
if event.type == pygame.QUIT: # If the program is closed:
done = True # To exit the loop
keys = pygame.key.get_pressed() # Moving the agent:
if keys[pygame.K_LEFT]: # Left:
# Checking if not a table, a kitchen, or a wall:
if y - 1 < 0 or grid[x][y - 1] == 1:
continue
else:
agent.move_left() # If okay, the move
if keys[pygame.K_RIGHT]: # The same procedure with right:
if y + 1 > 15 or grid[x][y + 1] == 1 or grid[x][y + 1] == 2:
continue
else:
agent.move_right()
if keys[pygame.K_UP]: # The same procedure with up:
if x - 1 < 0 or grid[x - 1][y] == 1 or grid[x - 1][y] == 2:
continue
else:
agent.move_up()
if keys[pygame.K_DOWN]: # The same procedure with down
if x + 1 > 15 or grid[x + 1][y] == 1 or grid[x + 1][y] == 2:
continue
else:
agent.move_down()
updateDraw()
customer()
clock.tick(60) # Limit to 60 frames per second
pygame.display.flip() # Updating the screen

29
final-evaluation.md Normal file
View File

@ -0,0 +1,29 @@
# Final Evaluation - Waiter Project
Authors: Tao Sen Chang, Martyna Druminska, Weronika Skowronska.
The project aim is to simulate waiter's behaviour in a restaurant
# Features
The waiter is able to move from table to table, choosing the most optimal way; It can decide whether the customer wants vegan menu or not, and evaluate the customer's plate as empty (waiting to order) full (eating) or dirty (and waiting for receipt)
# Route choosing
Author: Tao Sen Chang
At beginning of our project, we use reinforcement learning to get the shortest route for our agent to traversal specific tables. Reinforcement learning is how software agent ought to take actions in an environment in order to maximize the notion of cumulative reward. The agent makes a sequence of decisions, and learns to perform the best actions every step. After tons of training loops, the agent could get the optimal strategy which might collect maximal reward. In the case of our program, the “maximal reward”, would be to find the minimum distance to the customer, which in turn would save time and effort.
# Plate evaluation
Author: Weronika Skowronska
For this part, we used CNNs to classify the plate on the table as empty, full or dirty. CNN is a kind of Neural Networks, used to work with pictures - it's good in extracting features from a photo, and therefore it demands less computations than a fully connected layer used for the same task.
As it is often hard to say, if the client has done eating - if the waiter is not sure, he asks.
The state of the table is then passed to the table object, and is available for further actions.
# Client evaluation
Author: Martyna Druminska
If the plate is classified as empty - which means that the client hasn't ordered yet - we want to propose him a menu. We used decision trees to make a prediction on whether the person would like a vegan menu or not, based on the “customers” appearance (answers in the console). The decision tree algorithm learns off of a dataset with a diverse set of variables to make the best prediction. The program generates a flow-like structure that represents the decisions, where each node is a “test” on an attribute. The decision tree finishes when there are only leaf nodes left.
# Conclusions
We tried to perform an action as similar as possible to a real-life situation. In our opinion, we did pretty well - we managed to create a program that runs efficiently and cohesively to satisfy the needs of the customer.
One remark is that our program has little to do about clients' orders and the paying process - we think that one more subproject could solve this problem.

67
textpygame.py Normal file
View File

@ -0,0 +1,67 @@
import pygame
import pygame.font
import pygame.event
import pygame.draw
import os
import sys
from pygame.locals import *
bad_words_file = os.path.os.path.dirname(os.path.realpath(sys.argv[0])) \
+ '/bad_words.txt'
def get_key():
while 1:
event = pygame.event.poll()
if event.type == KEYDOWN:
return event.key
else:
pass
def display_box(screen, message):
"Print a message in a box in the middle of the screen"
fontobject = pygame.font.Font(None, 18)
pygame.draw.rect(screen, (0, 0, 0),
((screen.get_width() / 2) - 100,
(screen.get_height() / 2) - 10,
200, 20), 0)
pygame.draw.rect(screen, (255, 255, 255),
((screen.get_width() / 2) - 102,
(screen.get_height() / 2) - 12,
204, 24), 1)
if len(message) != 0:
screen.blit(fontobject.render(message, 1, (255, 255, 255)),
((screen.get_width() / 2) - 100, (screen.get_height() / 2) - 10))
pygame.display.flip()
def ask(screen, question):
"ask(screen, question) -> answer"
pygame.font.init()
current_string = []
display_box(screen, question + ": " + "".join(current_string))
while 1:
inkey = get_key()
if inkey == K_BACKSPACE:
current_string = current_string[0:-1]
elif inkey == K_RETURN:
file = open(bad_words_file, 'r').readlines()
if "".join(current_string) in [thing[:-1] for thing in file]:
current_string = []
else:
break
elif inkey == K_MINUS:
current_string.append("_")
elif inkey <= 127:
current_string.append(chr(inkey))
display_box(screen, question + ": " + "".join(current_string))
return "".join(current_string)
def main():
screen = pygame.display.set_mode((320, 240))
print(ask(screen, "Name") + " was entered")
if __name__ == '__main__': main()

751
veganism.csv Normal file
View File

@ -0,0 +1,751 @@
ethnicity,gender,appearence,vegan
asian,male,hippie,0
asian,male,hippie,1
asian,male,hippie,1
asian,male,hippie,0
asian,male,hippie,1
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,1
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,male,regular,0
asian,female,hippie,1
asian,female,hippie,1
asian,female,hippie,1
asian,female,hippie,1
asian,female,hippie,1
asian,female,hippie,1
asian,female,hippie,1
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
asian,female,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,1
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,male,regular,0
black,female,hippie,1
black,female,hippie,1
black,female,hippie,1
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,1
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
black,female,regular,0
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,0
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,0
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,hippie,1
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,male,regular,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,0
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,hippie,1
white,female,regular,0
white,female,regular,1
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,1
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
white,female,regular,0
1 ethnicity gender appearence vegan
2 asian male hippie 0
3 asian male hippie 1
4 asian male hippie 1
5 asian male hippie 0
6 asian male hippie 1
7 asian male regular 0
8 asian male regular 0
9 asian male regular 0
10 asian male regular 0
11 asian male regular 0
12 asian male regular 0
13 asian male regular 0
14 asian male regular 0
15 asian male regular 0
16 asian male regular 0
17 asian male regular 0
18 asian male regular 0
19 asian male regular 0
20 asian male regular 0
21 asian male regular 0
22 asian male regular 0
23 asian male regular 1
24 asian male regular 0
25 asian male regular 0
26 asian male regular 0
27 asian male regular 0
28 asian male regular 0
29 asian male regular 0
30 asian male regular 0
31 asian male regular 0
32 asian male regular 0
33 asian male regular 0
34 asian male regular 0
35 asian male regular 0
36 asian male regular 0
37 asian male regular 0
38 asian male regular 0
39 asian male regular 0
40 asian male regular 0
41 asian male regular 0
42 asian male regular 0
43 asian male regular 0
44 asian male regular 0
45 asian male regular 0
46 asian male regular 0
47 asian male regular 0
48 asian male regular 0
49 asian male regular 0
50 asian male regular 0
51 asian male regular 0
52 asian female hippie 1
53 asian female hippie 1
54 asian female hippie 1
55 asian female hippie 1
56 asian female hippie 1
57 asian female hippie 1
58 asian female hippie 1
59 asian female regular 0
60 asian female regular 0
61 asian female regular 0
62 asian female regular 0
63 asian female regular 0
64 asian female regular 0
65 asian female regular 0
66 asian female regular 0
67 asian female regular 0
68 asian female regular 0
69 asian female regular 0
70 asian female regular 0
71 asian female regular 0
72 asian female regular 0
73 asian female regular 0
74 asian female regular 0
75 asian female regular 0
76 asian female regular 0
77 asian female regular 0
78 asian female regular 0
79 asian female regular 0
80 asian female regular 0
81 asian female regular 0
82 asian female regular 0
83 asian female regular 0
84 asian female regular 0
85 asian female regular 0
86 asian female regular 0
87 asian female regular 0
88 asian female regular 0
89 asian female regular 0
90 asian female regular 0
91 asian female regular 0
92 asian female regular 0
93 asian female regular 0
94 asian female regular 0
95 asian female regular 0
96 asian female regular 0
97 asian female regular 0
98 asian female regular 0
99 asian female regular 0
100 asian female regular 0
101 asian female regular 0
102 black male regular 0
103 black male regular 0
104 black male regular 0
105 black male regular 0
106 black male regular 0
107 black male regular 0
108 black male regular 0
109 black male regular 0
110 black male regular 0
111 black male regular 0
112 black male regular 0
113 black male regular 0
114 black male regular 0
115 black male regular 0
116 black male regular 0
117 black male regular 0
118 black male regular 0
119 black male regular 0
120 black male regular 0
121 black male regular 0
122 black male regular 0
123 black male regular 0
124 black male regular 0
125 black male regular 0
126 black male regular 0
127 black male regular 0
128 black male regular 0
129 black male regular 0
130 black male regular 0
131 black male regular 0
132 black male regular 0
133 black male regular 0
134 black male regular 0
135 black male regular 1
136 black male regular 0
137 black male regular 0
138 black male regular 0
139 black male regular 0
140 black male regular 0
141 black male regular 0
142 black male regular 0
143 black male regular 0
144 black male regular 0
145 black male regular 0
146 black male regular 0
147 black male regular 0
148 black male regular 0
149 black male regular 0
150 black male regular 0
151 black male regular 0
152 black female hippie 1
153 black female hippie 1
154 black female hippie 1
155 black female regular 0
156 black female regular 0
157 black female regular 0
158 black female regular 0
159 black female regular 0
160 black female regular 0
161 black female regular 0
162 black female regular 0
163 black female regular 0
164 black female regular 0
165 black female regular 0
166 black female regular 0
167 black female regular 0
168 black female regular 0
169 black female regular 0
170 black female regular 0
171 black female regular 0
172 black female regular 0
173 black female regular 0
174 black female regular 0
175 black female regular 0
176 black female regular 0
177 black female regular 0
178 black female regular 0
179 black female regular 0
180 black female regular 0
181 black female regular 0
182 black female regular 0
183 black female regular 0
184 black female regular 0
185 black female regular 0
186 black female regular 0
187 black female regular 0
188 black female regular 0
189 black female regular 0
190 black female regular 0
191 black female regular 0
192 black female regular 0
193 black female regular 0
194 black female regular 1
195 black female regular 0
196 black female regular 0
197 black female regular 0
198 black female regular 0
199 black female regular 0
200 black female regular 0
201 black female regular 0
202 white male hippie 1
203 white male hippie 1
204 white male hippie 1
205 white male hippie 1
206 white male hippie 1
207 white male hippie 1
208 white male hippie 1
209 white male hippie 1
210 white male hippie 0
211 white male hippie 1
212 white male hippie 1
213 white male hippie 1
214 white male hippie 0
215 white male hippie 1
216 white male hippie 1
217 white male hippie 1
218 white male hippie 1
219 white male hippie 1
220 white male hippie 1
221 white male hippie 1
222 white male regular 0
223 white male regular 0
224 white male regular 0
225 white male regular 0
226 white male regular 0
227 white male regular 0
228 white male regular 0
229 white male regular 0
230 white male regular 0
231 white male regular 0
232 white male regular 0
233 white male regular 0
234 white male regular 0
235 white male regular 0
236 white male regular 0
237 white male regular 0
238 white male regular 0
239 white male regular 0
240 white male regular 0
241 white male regular 0
242 white male regular 0
243 white male regular 0
244 white male regular 0
245 white male regular 0
246 white male regular 0
247 white male regular 0
248 white male regular 0
249 white male regular 0
250 white male regular 0
251 white male regular 0
252 white male regular 0
253 white male regular 0
254 white male regular 0
255 white male regular 0
256 white male regular 0
257 white male regular 0
258 white male regular 0
259 white male regular 0
260 white male regular 0
261 white male regular 0
262 white male regular 0
263 white male regular 0
264 white male regular 0
265 white male regular 0
266 white male regular 0
267 white male regular 0
268 white male regular 0
269 white male regular 0
270 white male regular 0
271 white male regular 0
272 white male regular 0
273 white male regular 0
274 white male regular 0
275 white male regular 0
276 white male regular 0
277 white male regular 0
278 white male regular 0
279 white male regular 0
280 white male regular 0
281 white male regular 0
282 white male regular 0
283 white male regular 0
284 white male regular 0
285 white male regular 0
286 white male regular 0
287 white male regular 0
288 white male regular 0
289 white male regular 0
290 white male regular 0
291 white male regular 0
292 white male regular 0
293 white male regular 0
294 white male regular 0
295 white male regular 0
296 white male regular 0
297 white male regular 0
298 white male regular 0
299 white male regular 0
300 white male regular 0
301 white male regular 0
302 white male regular 0
303 white male regular 0
304 white male regular 0
305 white male regular 0
306 white male regular 0
307 white male regular 0
308 white male regular 0
309 white male regular 0
310 white male regular 0
311 white male regular 0
312 white male regular 0
313 white male regular 0
314 white male regular 0
315 white male regular 0
316 white male regular 0
317 white male regular 0
318 white male regular 0
319 white male regular 0
320 white male regular 0
321 white male regular 0
322 white male regular 0
323 white male regular 0
324 white male regular 0
325 white male regular 0
326 white male regular 0
327 white male regular 0
328 white male regular 0
329 white male regular 0
330 white male regular 0
331 white male regular 0
332 white male regular 0
333 white male regular 0
334 white male regular 0
335 white male regular 0
336 white male regular 0
337 white male regular 0
338 white male regular 0
339 white male regular 0
340 white male regular 0
341 white male regular 0
342 white male regular 0
343 white male regular 0
344 white male regular 0
345 white male regular 0
346 white male regular 0
347 white male regular 0
348 white male regular 0
349 white male regular 0
350 white male regular 0
351 white male regular 0
352 white male regular 0
353 white male regular 0
354 white male regular 0
355 white male regular 0
356 white male regular 0
357 white male regular 0
358 white male regular 0
359 white male regular 0
360 white male regular 0
361 white male regular 0
362 white male regular 0
363 white male regular 0
364 white male regular 0
365 white male regular 0
366 white male regular 0
367 white male regular 0
368 white male regular 0
369 white male regular 0
370 white male regular 0
371 white male regular 0
372 white male regular 0
373 white male regular 0
374 white male regular 0
375 white male regular 0
376 white male regular 0
377 white male regular 0
378 white male regular 0
379 white male regular 0
380 white male regular 0
381 white male regular 0
382 white male regular 0
383 white male regular 0
384 white male regular 0
385 white male regular 0
386 white male regular 0
387 white male regular 0
388 white male regular 0
389 white male regular 0
390 white male regular 0
391 white male regular 0
392 white male regular 0
393 white male regular 0
394 white male regular 0
395 white male regular 0
396 white male regular 0
397 white male regular 0
398 white male regular 0
399 white male regular 0
400 white male regular 0
401 white male regular 0
402 white male regular 0
403 white male regular 0
404 white male regular 0
405 white male regular 0
406 white male regular 0
407 white male regular 0
408 white male regular 0
409 white male regular 0
410 white male regular 0
411 white male regular 0
412 white male regular 0
413 white male regular 0
414 white male regular 0
415 white male regular 0
416 white male regular 0
417 white male regular 0
418 white male regular 0
419 white male regular 0
420 white male regular 0
421 white male regular 0
422 white male regular 0
423 white male regular 0
424 white male regular 0
425 white male regular 0
426 white male regular 0
427 white male regular 0
428 white male regular 0
429 white male regular 0
430 white male regular 0
431 white male regular 0
432 white male regular 0
433 white male regular 0
434 white male regular 0
435 white male regular 0
436 white male regular 0
437 white male regular 0
438 white male regular 0
439 white male regular 0
440 white male regular 0
441 white male regular 0
442 white male regular 0
443 white male regular 0
444 white male regular 0
445 white male regular 0
446 white male regular 0
447 white male regular 0
448 white male regular 0
449 white male regular 0
450 white male regular 0
451 white male regular 0
452 white male regular 0
453 white male regular 0
454 white male regular 0
455 white male regular 0
456 white male regular 0
457 white male regular 0
458 white male regular 0
459 white male regular 0
460 white male regular 0
461 white male regular 0
462 white male regular 0
463 white male regular 0
464 white male regular 0
465 white male regular 0
466 white male regular 0
467 white male regular 0
468 white male regular 0
469 white male regular 0
470 white male regular 0
471 white male regular 0
472 white male regular 0
473 white male regular 0
474 white male regular 0
475 white male regular 0
476 white male regular 0
477 white female hippie 1
478 white female hippie 1
479 white female hippie 1
480 white female hippie 1
481 white female hippie 1
482 white female hippie 1
483 white female hippie 1
484 white female hippie 1
485 white female hippie 1
486 white female hippie 1
487 white female hippie 1
488 white female hippie 1
489 white female hippie 1
490 white female hippie 1
491 white female hippie 1
492 white female hippie 1
493 white female hippie 1
494 white female hippie 1
495 white female hippie 1
496 white female hippie 1
497 white female hippie 1
498 white female hippie 1
499 white female hippie 1
500 white female hippie 1
501 white female hippie 1
502 white female hippie 1
503 white female hippie 1
504 white female hippie 0
505 white female hippie 1
506 white female hippie 1
507 white female hippie 1
508 white female hippie 1
509 white female hippie 1
510 white female hippie 0
511 white female hippie 1
512 white female hippie 1
513 white female hippie 1
514 white female hippie 1
515 white female hippie 1
516 white female hippie 0
517 white female hippie 1
518 white female hippie 1
519 white female hippie 1
520 white female hippie 1
521 white female hippie 1
522 white female hippie 1
523 white female hippie 0
524 white female hippie 0
525 white female hippie 1
526 white female hippie 1
527 white female hippie 1
528 white female hippie 1
529 white female hippie 1
530 white female hippie 1
531 white female hippie 1
532 white female hippie 0
533 white female hippie 1
534 white female hippie 1
535 white female hippie 1
536 white female hippie 1
537 white female hippie 1
538 white female hippie 0
539 white female hippie 1
540 white female hippie 1
541 white female hippie 0
542 white female hippie 1
543 white female hippie 1
544 white female hippie 1
545 white female hippie 0
546 white female hippie 1
547 white female hippie 1
548 white female hippie 1
549 white female hippie 1
550 white female hippie 1
551 white female hippie 1
552 white female hippie 1
553 white female hippie 0
554 white female hippie 1
555 white female hippie 1
556 white female hippie 1
557 white female hippie 1
558 white female hippie 0
559 white female hippie 1
560 white female hippie 0
561 white female hippie 1
562 white female hippie 1
563 white female hippie 1
564 white female hippie 1
565 white female hippie 1
566 white female hippie 1
567 white female regular 0
568 white female regular 1
569 white female regular 0
570 white female regular 0
571 white female regular 0
572 white female regular 0
573 white female regular 0
574 white female regular 0
575 white female regular 0
576 white female regular 0
577 white female regular 0
578 white female regular 0
579 white female regular 0
580 white female regular 0
581 white female regular 0
582 white female regular 0
583 white female regular 0
584 white female regular 0
585 white female regular 0
586 white female regular 0
587 white female regular 0
588 white female regular 0
589 white female regular 0
590 white female regular 0
591 white female regular 0
592 white female regular 0
593 white female regular 0
594 white female regular 0
595 white female regular 0
596 white female regular 0
597 white female regular 0
598 white female regular 0
599 white female regular 0
600 white female regular 0
601 white female regular 0
602 white female regular 0
603 white female regular 0
604 white female regular 0
605 white female regular 0
606 white female regular 0
607 white female regular 0
608 white female regular 0
609 white female regular 0
610 white female regular 0
611 white female regular 0
612 white female regular 0
613 white female regular 0
614 white female regular 0
615 white female regular 0
616 white female regular 0
617 white female regular 0
618 white female regular 0
619 white female regular 0
620 white female regular 0
621 white female regular 0
622 white female regular 0
623 white female regular 0
624 white female regular 0
625 white female regular 0
626 white female regular 0
627 white female regular 0
628 white female regular 0
629 white female regular 0
630 white female regular 0
631 white female regular 0
632 white female regular 0
633 white female regular 0
634 white female regular 0
635 white female regular 0
636 white female regular 0
637 white female regular 0
638 white female regular 0
639 white female regular 0
640 white female regular 0
641 white female regular 0
642 white female regular 0
643 white female regular 0
644 white female regular 0
645 white female regular 0
646 white female regular 0
647 white female regular 0
648 white female regular 0
649 white female regular 0
650 white female regular 0
651 white female regular 0
652 white female regular 0
653 white female regular 0
654 white female regular 0
655 white female regular 0
656 white female regular 0
657 white female regular 0
658 white female regular 0
659 white female regular 0
660 white female regular 0
661 white female regular 0
662 white female regular 0
663 white female regular 0
664 white female regular 0
665 white female regular 0
666 white female regular 0
667 white female regular 0
668 white female regular 0
669 white female regular 0
670 white female regular 0
671 white female regular 0
672 white female regular 0
673 white female regular 0
674 white female regular 0
675 white female regular 0
676 white female regular 0
677 white female regular 0
678 white female regular 0
679 white female regular 0
680 white female regular 0
681 white female regular 0
682 white female regular 0
683 white female regular 0
684 white female regular 0
685 white female regular 0
686 white female regular 0
687 white female regular 0
688 white female regular 0
689 white female regular 0
690 white female regular 0
691 white female regular 0
692 white female regular 0
693 white female regular 0
694 white female regular 0
695 white female regular 0
696 white female regular 0
697 white female regular 0
698 white female regular 0
699 white female regular 0
700 white female regular 0
701 white female regular 0
702 white female regular 0
703 white female regular 0
704 white female regular 0
705 white female regular 0
706 white female regular 0
707 white female regular 0
708 white female regular 0
709 white female regular 0
710 white female regular 0
711 white female regular 0
712 white female regular 0
713 white female regular 0
714 white female regular 0
715 white female regular 0
716 white female regular 0
717 white female regular 0
718 white female regular 1
719 white female regular 0
720 white female regular 0
721 white female regular 0
722 white female regular 0
723 white female regular 0
724 white female regular 0
725 white female regular 0
726 white female regular 0
727 white female regular 0
728 white female regular 0
729 white female regular 0
730 white female regular 0
731 white female regular 0
732 white female regular 0
733 white female regular 0
734 white female regular 0
735 white female regular 0
736 white female regular 0
737 white female regular 0
738 white female regular 0
739 white female regular 0
740 white female regular 0
741 white female regular 0
742 white female regular 0
743 white female regular 0
744 white female regular 0
745 white female regular 0
746 white female regular 0
747 white female regular 0
748 white female regular 0
749 white female regular 0
750 white female regular 0
751 white female regular 0

478
waiter1406.py Normal file
View File

@ -0,0 +1,478 @@
#### MD #######
import pandas as pd
import pygame
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from pygame.locals import *
import numpy as np
import matplotlib.pyplot as plt
from sklearn import tree
import random
from textpygame import get_key, ask, display_box
###### /MD ######
import math
import pickle
########################
### WS ###
########################
# For CNN:
import keras
from keras.preprocessing import image
from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
#initializing:
cnn_model = Sequential()
#Convolution:
cnn_model.add(Convolution2D(32, (3, 3), input_shape =(256, 256, 3), activation = "relu"))
#Pooling:
cnn_model.add(MaxPooling2D(pool_size = (2,2)))
# Adding a second convolutional layer
cnn_model.add(Convolution2D(32, 3, 3, activation = 'relu'))
cnn_model.add(MaxPooling2D(pool_size = (2, 2)))
#Flattening:
cnn_model.add(Flatten())
#Fully connected layers::
cnn_model.add(Dense(units = 128, activation = "relu"))
cnn_model.add(Dense(units = 3, activation = "softmax"))
# loading weigjts:
cnn_model.load_weights('s444523/best_model_weights2.h5')
#Making CNN:
cnn_model.compile(optimizer = "adam", loss = "categorical_crossentropy", metrics = ["accuracy"])
########################
### /WS ###
########################
#### MD#####
#read csv file
dataset= pd.read_csv("veganism.csv")
#create a new dataset
newdataset = pd.DataFrame(dataset, columns=['ethnicity', 'gender', 'appearence', 'vegan'])
# creating instance of labelencoder
labelencoder = LabelEncoder()
# Assigning numerical values and storing in another column
newdataset['ethnicity_no'] = labelencoder.fit_transform(newdataset['ethnicity'])
newdataset['gender_no']= labelencoder.fit_transform(newdataset['gender'])
newdataset['appearence_no']= labelencoder.fit_transform(newdataset['appearence'])
# for x values drop unimportant columns, axis=1 specifies that we want the columns not rows
Y=newdataset['vegan']
X=newdataset.drop(newdataset.columns[0:4], axis=1)
#test 14% of the data
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.15)
classifier = DecisionTreeClassifier()
classifier.fit(X_train, Y_train)
y_pred = classifier.predict(X_test)
fn=['ethnicity','gender','appearence']
cn=['yes', 'no']
# Setting dpi = 300 to make image clearer than default (for the decision tree visualisation)
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (4,4), dpi=300)
tree.plot_tree(classifier,
feature_names = fn,
class_names=cn,
filled = True);
fig.savefig('imagenamenew.png')
class Customer:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j,1 , 4)
class CustomerPlace:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j,1 , 5)
###### /MD #######
# Colors:
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 240)
YELLOW = (255, 255, 0)
#Width and Height of each square:
WIDTH = 20
HEIGHT = 20
#Margin:
MARGIN = 5
grid = [[0 for x in range(16)] for y in range(16)]
def change_value(i, j, width, n):
for r in range (i, i+width):
for c in range (j, j+width):
grid[r][c] = n
class Table:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j, 2, 1)
def get_destination_coor(self):
return [self.coordinate_i+2, self.coordinate_j+2]
########################
### WS ###
########################
# The finction "state of meal" chooses a photo of a plate at the given table.
def state_of_meal(self):
## !!!!!!###
num = np.random.randint(67, 100)
## !!!!!!###
if num<=67:
img_name = 'plates/{}.png'.format(num)
else:
img_name = 'plates/{}.jpg'.format(num)
return img_name
# The function "change state" changes the value of the state variable.
# It informs, whether the client are waiting for the waiter to make an order
# (0 - empty plates) are eating (2 - full plates) or are waiting for the
# waiter to get a recipt (1 - dirty plates)
def change_state(self, st):
self.state = st
########################
### /WS ###
########################
class Kitchen:
def __init__(self, coordinate_i, coordinate_j):
self.coordinate_i = coordinate_i
self.coordinate_j = coordinate_j
change_value(coordinate_i, coordinate_j, 3, 2)
class Agent:
def __init__(self,orig_coordinate_i, orig_coordinate_j):
self.orig_coordinate_i = orig_coordinate_i
self.orig_coordinate_j = orig_coordinate_j
self.state = np.array([orig_coordinate_i,orig_coordinate_j])
change_value(orig_coordinate_j, orig_coordinate_j, 1, 3)
self.state_update(orig_coordinate_i, orig_coordinate_j)
def state_update(self, c1, c2):
self.state[0] = c1
self.state[1] = c2
def leave(self):
change_value(self.state[0], self.state[1], 1, 0)
def move_to(self, nextPos):
self.leave()
nextPos_x, nextPos_y = nextPos
self.state_update(nextPos_x, nextPos_y)
change_value(self.state[0], self.state[1], 1, 3)
########################
### WS ###
########################
#The function "define_table" serches for the apropriate table in the
# table_dict (to enable the usage of class attributes and methods)
def define_table(self, t_num):
t_num = 'table{}'.format(t_num)
t_num = table_dict[t_num]
return t_num
# The function "check_plates" uses the pretrained CNN model to classify
# the plate on the table as empty(0), full(2) or dirty(1)
def check_plates(self, table_number):
table = self.define_table(table_number)
plate = table.state_of_meal()
plate= image.load_img(plate, target_size = (256, 256))
plate = image.img_to_array(plate)
#plate = plate.reshape((256, 256))
plate = np.expand_dims(plate, axis = 0)
result = cnn_model.predict(plate)[0]
print(result)
if result[1] == 1:
result[1] = 0
x = int(input("Excuse me, have You done eating? 1=Yes, 2 = No \n"))
result[x] = 1
for i, x in enumerate(result):
if result[i] == 1:
table.change_state(i)
return i
########################
### /WS ###
########################
def check_done():
for event in pygame.event.get(): # Checking for the event
if event.type == pygame.QUIT: # If the program is closed:
return True # To exit the loop
def draw_grid():
for row in range(16): # Drawing the grid
for column in range(16):
color = WHITE
if grid[row][column] == 1:
color = GREEN
if grid[row][column] == 2:
color = RED
if grid[row][column] == 3:
color = BLUE
pygame.draw.rect(screen,
color,
[(MARGIN + WIDTH) * column + MARGIN,
(MARGIN + HEIGHT) * row + MARGIN,
WIDTH,
HEIGHT])
## default positions of the agent:
x = 12
y = 12
agent = Agent(x, y)
table1 = Table(2, 2)
table2 = Table (2,7)
table3 = Table(2, 12)
table4 = Table(7, 2)
table5 = Table(7, 7)
table6 = Table(7, 12)
table7 = Table(12, 2)
table8 = Table(12, 7)
################### WS #####################
# I added the dict to loop through tables.
table_dict = {"table1":table1, "table2":table2, "table3":table3,"table4":table4,
"table5":table5,"table6":table6,"table7":table7,"table8":table8
}
################### WS #####################
pygame.init()
####MD ####
'''
# create a font object.
# 1st parameter is the font file
# which is present in pygame.
# 2nd parameter is size of the font
font = pygame.font.Font('freesansbold.ttf', 14)
X = 400
Y = 400
# create a text suface object,
# on which text is drawn on it.
text = font.render('waiter: hello, let me help you with your order.', True, WHITE, BLACK)
userText=font.render('user: ', True, BLUE, BLACK)
# create a rectangular object for the
# text surface object
textRect = text.get_rect()
inputRect = userText.get_rect()
# set the center of the rectangular object.
textRect.center= (200, 340)
inputRect.center=(200,370)
'''
#### /MD ####
#class Kitchen:
kitchen = Kitchen(13, 13)
WINDOW_SIZE = [405, 405]
screen = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("Waiter_Grid3")
done = False
clock = pygame.time.Clock()
with open('res_targets_4-1.data', 'rb') as filehandle:
# read the data as binary data stream
trained_route = pickle.load(filehandle)
destination = (4, 14)
trained_route.append(destination)
table_targets = [(9, 4),(4, 4),(4, 9),(4, 14)]
destination_tables = []
###### MD /########3
x=[2,7,12]
y=[2,7]
random_customer_seat_x=random.choice(x)
random_customer_seat_y=random.choice(y)
print(random_customer_seat_x,random_customer_seat_y)
seat=Customer(random_customer_seat_x,random_customer_seat_y)
next_to=CustomerPlace(random_customer_seat_x,random_customer_seat_y-1)
WINDOW_SIZE = [405, 405]
screen = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("Waiter_Grid3")
done = False
print(random_customer_seat_x,random_customer_seat_y-1)
clock = pygame.time.Clock()
#updating the drawing
def updateDraw():
x = agent.state[0]
y = agent.state[1]
screen.fill(BLACK) # Background color
for row in range(16): # Drawing the grid
for column in range(16):
color = WHITE
if grid[row][column] == 1:
color = GREEN
if grid[row][column] == 2:
color = RED
if grid[row][column] == 3:
color = BLUE
if grid[row][column] == 4:
color = MAGENTA
surface = pygame.draw.rect(screen,
color,
[(MARGIN + WIDTH) * column + MARGIN,
(MARGIN + HEIGHT) * row + MARGIN,
WIDTH,
HEIGHT])
def customer():
screen.blit(text, textRect)
ethnicity3 = input("Excuse me, What's you're ethnicity? <black>, <asian>, <white>\n")
gender3= input("Excuse me, What's you're gender? <male>, <female>, <other> \n")
appearence3=input("Excuse me, What's you're appearance? <hippie>, <other> \n")
if (ethnicity3 =="black"):
ethnicity3 = 1
elif ethnicity3 == "asian":
ethnicity3 = 0
else:
ethnicity3 = 2
if gender3 == "male":
gender3 = 0
else:
gender3 = 1
if appearence3 == "hippie":
appearence3= 0
else:
appearence3 = 1
prediction = classifier.predict([[ethnicity3, gender3, appearence3]])
#pygame.quit()
if prediction == [0]:
print("You're probably not vegan. Would you like a regular menu?")
else:
print("It seems like you're vegan. Would you like a vegan menu?")
#exit()
###### /MD ###
# -------- Main Program Loop -----------
exit_counter = 0
while not done:
screen.fill(BLACK) # Background color
draw_grid()
done = check_done()
new_route = trained_route[:]
for value in table_dict.values():
destination_tables.append(value.get_destination_coor())
num_of_table = 1
while len(new_route) != 0:
# move to next grid
agent.move_to(new_route[0])
# update the grid
pygame.time.delay(150)
screen.fill(BLACK)
draw_grid()
# Drawing the grid
clock.tick(100) # Limit to 60 frames per second
pygame.display.flip() # Updating the screen
# get current grid coordinate
x = agent.state[0]
y = agent.state[1]
# if reached the table, ask to collect the plates
if [x, y] in destination_tables:
########################
### WS ###
########################
#pygame.time.delay(100)
print("I'm at a table no. {}".format(num_of_table))
## Checking at what state are the plates:
state_of_table = agent.check_plates(num_of_table)
num_of_table +=1
if state_of_table == 0:
customer()
# Early stopping (after 10 rounds)
exit_counter += 1
print("exit_counter", exit_counter)
if exit_counter == 10:
play_again = 1
play_again = int(input("Exit? 0=No, 1=Yes \n"))
if play_again:
pygame.quit()
else:
exit_counter = 0
########################
### /WS ###
########################
destination_tables = destination_tables[1:]
new_route = new_route[1:]
# After each fool loop, we can quit the program:.
pygame.quit()