diff --git a/.idea/misc.xml b/.idea/misc.xml index 8eab719..715ed69 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/.idea/wozek.iml b/.idea/wozek.iml index 004f809..b1bd648 100644 --- a/.idea/wozek.iml +++ b/.idea/wozek.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/__pycache__/data.cpython-37.pyc b/__pycache__/data.cpython-37.pyc index 196eabc..6a5342b 100644 Binary files a/__pycache__/data.cpython-37.pyc and b/__pycache__/data.cpython-37.pyc differ diff --git a/__pycache__/decision_tree.cpython-37.pyc b/__pycache__/decision_tree.cpython-37.pyc index 5b41fdd..ae6781a 100644 Binary files a/__pycache__/decision_tree.cpython-37.pyc and b/__pycache__/decision_tree.cpython-37.pyc differ diff --git a/data.py b/data.py index b8e059f..4c3a444 100644 --- a/data.py +++ b/data.py @@ -40,7 +40,7 @@ learning_data = [ ['gold', 'rectangle', 40, 'medium', 'Twix'], ['gold', 'rectangle', 50, 'medium', 'Prince-polo'], ['brown', 'rectangle', 55, 'medium', 'Snickers'], - ['brown', 'rectangle', 45, 'medium', 'Lion'], + ['brown', 'rectangle', 45, 'medium', 'Lion'], ['white', 'rectangle', 40, 'medium', 'Kinder-bueno'], ['red', 'rectangle', 50, 'medium', 'Kit-kat'], ['blue', 'rectangle', 115, 'big', 'Wedel'], diff --git a/decision_tree.py b/decision_tree.py index 1f6c05b..48a1d3a 100644 --- a/decision_tree.py +++ b/decision_tree.py @@ -62,15 +62,14 @@ def partition(rows, question): def gini(rows): - """ Gini impurity is a measure of how often a randomly chosen element from - the set would be incorrectly labeled if it was randomly labeled according to - the distribution of labels in the subset. """ + """ Gini impurity to miara tego jak często losowo wybrany element zbioru byłby źle skategoryzowany, gdyby + przypisać mu losową kategorię spośród wszystkich kategorii znajdujących się w danym zbiorze. """ counts = class_counts(rows) - impurity = 1 + impurity = 0 for lbl in counts: prob_of_lbl = counts[lbl] / float(len(rows)) - impurity -= prob_of_lbl ** 2 + impurity += prob_of_lbl * (1 - prob_of_lbl) return impurity @@ -169,16 +168,15 @@ def print_leaf(counts): # print_tree(my_tree) # # testing_data = [ -# ['gold', 'rectangle', 50, 'medium', 'Name'], -# ['brown', 'rectangle', 55, 'medium', 'Snickers'], -# ['white', 'rectangle', 120, 'big', 'Name'] +# ['red', 'rectangle', 50, 'medium', 'Kit-kat'], +# ['blue', 'rectangle', 115, 'big', 'Wedel'], +# ['white', 'rectangle', 15, 'small', 'Krowka'], # ] # -# test = ['white', 'rectangle', 120, 'big', 'Name'] +# test = ['white', 'rectangle', 15, 'small', 'Krowka'] # -# # for row in testing_data: -# # print(print_leaf(classify(row, my_tree))) +# for row in testing_data: +# print(print_leaf(classify(row, my_tree))) # # wynik = print_leaf(classify(test, my_tree))[0] # print(wynik) - diff --git a/environment.yml b/environment.yml index 2d225c4..2d49dc6 100644 Binary files a/environment.yml and b/environment.yml differ diff --git a/img/shelf.png b/img/shelf.png index 3e443f0..47b4aa4 100644 Binary files a/img/shelf.png and b/img/shelf.png differ diff --git a/main.py b/main.py index cb61a47..177f331 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ from board import create_board, draw_board from random import randint, choice from mcda import choseProducts + # Inicjalizacja programu i utworzenie obiektu ekrany def run(): pygame.init() @@ -44,7 +45,6 @@ def run(): agent.turn_left() elif event.key == pygame.K_UP: agent.move_forward(board) - print(agent.x, agent.y) elif event.key == pygame.K_SPACE: board[9][0].item = choice(data.learning_data) print("Wybrano: " + board[9][0].item[-1])