This commit is contained in:
Wojciech Łukasik 2020-06-08 18:21:02 +02:00
parent 8e18c0f39e
commit dceb5bd8d5
9 changed files with 14 additions and 16 deletions

View File

@ -3,5 +3,5 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (AL-2020)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (AL-2020)" project-jdk-type="Python SDK" />
</project>

View File

@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.8 (AL-2020)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.7 (AL-2020)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

View File

@ -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'],

View File

@ -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)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 849 B

View File

@ -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])