2
0
forked from s444420/AL-2020

Merge branch 'master' of s444428/AL-2020 into master

This commit is contained in:
Wojciech Łukasik 2020-05-19 11:37:31 +00:00 committed by Gogs
commit 7777b4cc6b
16 changed files with 1191 additions and 581 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.7" 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

@ -2,10 +2,19 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="">
<<<<<<< HEAD
<change afterPath="$PROJECT_DIR$/decision_tree.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Archiwum/frontend/js/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/Archiwum/frontend/js/main.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/data.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/field.py" beforeDir="false" afterPath="$PROJECT_DIR$/field.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
=======
<change afterPath="$PROJECT_DIR$/Assiging/datadict.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assiging/feature_hashing.py" beforeDir="false" afterPath="$PROJECT_DIR$/Assiging/feature_hashing.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/data.py" afterDir="false" />
>>>>>>> upstream/master
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -35,10 +44,15 @@
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/decision_tree.py" />
<property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Studia\Projects\AL-2020" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
@ -74,6 +88,9 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<<<<<<< HEAD
<configuration name="main" type="PythonConfigurationType" factoryName="Python">
=======
<configuration name="feature_hashing" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -97,6 +114,7 @@
<method v="2" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
>>>>>>> upstream/master
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
@ -119,6 +137,13 @@
<method v="2" />
</configuration>
<list>
<<<<<<< HEAD
<item itemvalue="Python.main" />
<item itemvalue="Python.board" />
</list>
<recent_temporary>
<list>
=======
<item itemvalue="Python.board" />
<item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" />
@ -127,6 +152,7 @@
<list>
<item itemvalue="Python.feature_hashing" />
<item itemvalue="Python.main" />
>>>>>>> upstream/master
<item itemvalue="Python.board" />
</list>
</recent_temporary>
@ -145,6 +171,11 @@
<workItem from="1589233530634" duration="769000" />
<workItem from="1589543001064" duration="78000" />
<workItem from="1589543305930" duration="10474000" />
<<<<<<< HEAD
<workItem from="1589561555146" duration="3518000" />
<workItem from="1589727068958" duration="5729000" />
<workItem from="1589796372999" duration="4340000" />
=======
<workItem from="1589561555146" duration="3374000" />
<workItem from="1589745328635" duration="27000" />
<workItem from="1589745409339" duration="739000" />
@ -172,6 +203,7 @@
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1589822196451</updated>
>>>>>>> upstream/master
</task>
<option name="localTasksCounter" value="4" />
<servers />
@ -199,8 +231,14 @@
<option name="LAST_COMMIT_MESSAGE" value="changed CreateDataSweets to lowercase" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<<<<<<< HEAD
<SUITE FILE_PATH="coverage/AL_2020$decision_tree.coverage" NAME="main Coverage Results" MODIFIED="1589815629629" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/wozek$board.coverage" NAME="board Coverage Results" MODIFIED="1589210811600" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589729320403" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
=======
<SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589754127142" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/AL_2020$feature_hashing.coverage" NAME="feature_hashing Coverage Results" MODIFIED="1589823737949" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Assiging" />
>>>>>>> upstream/master
<SUITE FILE_PATH="coverage/wozek$main.coverage" NAME="main Coverage Results" MODIFIED="1589556038208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/wozek$board.coverage" NAME="board Coverage Results" MODIFIED="1589210811600" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>

245
.idea/workspace.xml.orig Normal file
View File

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="">
<<<<<<< HEAD
<change afterPath="$PROJECT_DIR$/decision_tree.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Archiwum/frontend/js/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/Archiwum/frontend/js/main.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/data.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/field.py" beforeDir="false" afterPath="$PROJECT_DIR$/field.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
=======
<change afterPath="$PROJECT_DIR$/Assiging/datadict.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assiging/feature_hashing.py" beforeDir="false" afterPath="$PROJECT_DIR$/Assiging/feature_hashing.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/data.py" afterDir="false" />
>>>>>>> upstream/master
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1blUxWbA3VMjMFjk8gUnLGMgAoU" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/decision_tree.py" />
<property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Studia\Projects\AL-2020" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python.feature_hashing">
<configuration name="board" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/board.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<<<<<<< HEAD
<configuration name="main" type="PythonConfigurationType" factoryName="Python">
=======
<configuration name="feature_hashing" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Assiging" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/Assiging/feature_hashing.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
>>>>>>> upstream/master
<module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<list>
<<<<<<< HEAD
<item itemvalue="Python.main" />
<item itemvalue="Python.board" />
</list>
<recent_temporary>
<list>
=======
<item itemvalue="Python.board" />
<item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.feature_hashing" />
<item itemvalue="Python.main" />
>>>>>>> upstream/master
<item itemvalue="Python.board" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="" />
<created>1589206421672</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1589206421672</updated>
<workItem from="1589206439279" duration="11691000" />
<workItem from="1589233530634" duration="769000" />
<workItem from="1589543001064" duration="78000" />
<workItem from="1589543305930" duration="10474000" />
<<<<<<< HEAD
<workItem from="1589561555146" duration="3518000" />
<workItem from="1589727068958" duration="5729000" />
<workItem from="1589796372999" duration="4340000" />
=======
<workItem from="1589561555146" duration="3374000" />
<workItem from="1589745328635" duration="27000" />
<workItem from="1589745409339" duration="739000" />
<workItem from="1589752301424" duration="1007000" />
<workItem from="1589753322316" duration="835000" />
<workItem from="1589814601057" duration="4208000" />
</task>
<task id="LOCAL-00001" summary="create Shelf">
<created>1589815443652</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1589815443652</updated>
</task>
<task id="LOCAL-00002" summary="create addShelf method in Field class">
<created>1589816028640</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1589816028640</updated>
</task>
<task id="LOCAL-00003" summary="changed CreateDataSweets to lowercase">
<created>1589822196451</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1589822196451</updated>
>>>>>>> upstream/master
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="COLUMN_ORDER" />
</State>
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="create Shelf" />
<MESSAGE value="create addShelf method in Field class" />
<MESSAGE value="changed CreateDataSweets to lowercase" />
<option name="LAST_COMMIT_MESSAGE" value="changed CreateDataSweets to lowercase" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<<<<<<< HEAD
<SUITE FILE_PATH="coverage/AL_2020$decision_tree.coverage" NAME="main Coverage Results" MODIFIED="1589815629629" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/wozek$board.coverage" NAME="board Coverage Results" MODIFIED="1589210811600" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589729320403" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
=======
<SUITE FILE_PATH="coverage/AL_2020$main.coverage" NAME="main Coverage Results" MODIFIED="1589754127142" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/AL_2020$feature_hashing.coverage" NAME="feature_hashing Coverage Results" MODIFIED="1589823737949" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Assiging" />
>>>>>>> upstream/master
<SUITE FILE_PATH="coverage/wozek$main.coverage" NAME="main Coverage Results" MODIFIED="1589556038208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/wozek$board.coverage" NAME="board Coverage Results" MODIFIED="1589210811600" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</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.7" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.7 (AL-2020)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
candy.py Normal file
View File

@ -0,0 +1,9 @@
class Candy:
def __init__(self, producent, type, price):
self.producent = producent
self.type = type
self.price = price

32
data.py
View File

@ -28,6 +28,38 @@ def create_data_sweets():
return allProducts
learning_data = [
# kolor, kształt, waga, rozmiar, nazwa
['black', 'rectangle', 51, 'small', 'Mars'],
['gold', 'pack', 100, 'big', 'Haribo'],
['purple', 'rectangle', 100, 'big', 'Milka'],
['brown', 'pack', 45, 'small', 'M&M'],
['blue', 'rectangle', 50, 'medium', 'Bounty'],
['blue', 'square', 40, 'small', 'Knoppers'],
['blue', 'rectangle', 35, 'small', 'Milky-way'],
['gold', 'rectangle', 40, 'medium', 'Twix'],
['gold', 'rectangle', 50, 'medium', 'Prince-polo'],
['brown', 'rectangle', 55, 'medium', 'Snickers'],
['brown', 'rectangle', 45, 'medium', 'Lion'],
['white', 'rectangle', 40, 'medium', 'Kinder-bueno'],
['red', 'rectangle', 50, 'medium', 'Kit-kat'],
['blue', 'rectangle', 115, 'big', 'Wedel'],
['white', 'rectangle', 15, 'small', 'Krowka'],
['red', 'pack', 70, 'medium', 'Skittles'],
['orange', 'rectangle', 45, 'medium', 'Reeses'],
['blue', 'rectangle', 55, 'medium', 'Oreo'],
['gold', 'rectangle', 120, 'big', 'Ferrero-rocher'],
['white', 'rectangle', 120, 'big', 'Rafaello'],
['white', 'jar', 600, 'big', 'Nutella'],
['white', 'rectangle', 25, 'small', 'Duplo'],
['brown', 'jar', 500, 'big', 'GoOn'],
['brown', 'jar', 470, 'big', 'Active Orzechowe'],
['red', 'jar', 250, 'medium', 'Strawberry Jam'],
['black', 'jar', 250, 'medium', 'Blackberry Jam'],
['orange', 'jar', 250, 'medium', 'Peach Jam'],
]
def create_data_dict():
products_as_dict = []

91
data.py.orig Normal file
View File

@ -0,0 +1,91 @@
from sweets import Sweets
def create_data_sweets():
allProducts = []
sweet = Sweets('Mars', 'czekoladowy', 'baton', 'sredni', 2.49)
allProducts.append(sweet)
sweet = Sweets('Mars', 'czekoladowy', 'czekolada', 'duzy', 4.99)
allProducts.append(sweet)
sweet = Sweets('Mars', 'czekoladowy', 'czekolada', 'ogromny', 11.26)
allProducts.append(sweet)
sweet = Sweets('M&M', 'czekoladowy', 'czekolada', 'duzy', 3.99)
allProducts.append(sweet)
sweet = Sweets('M&M', 'czekoladowy', 'baton', 'sredni', 2.89)
allProducts.append(sweet)
sweet = Sweets('Nestle', 'bananowy', 'landrynka', 'maly', 0.39)
allProducts.append(sweet)
sweet = Sweets('Nestle', 'truskawkowy', 'landrynka', 'maly', 0.39)
allProducts.append(sweet)
sweet = Sweets('Nestle', 'cola', 'landrynka', 'maly', 0.49)
allProducts.append(sweet)
sweet = Sweets('Wedel', 'czekoladowy', 'baton', 'sredni', 1.99)
allProducts.append(sweet)
sweet = Sweets('Maoam', 'truskawkowy', 'guma', 'maly', 0.25)
allProducts.append(sweet)
<<<<<<< HEAD
return allProducts
learning_data = [
# kolor, kształt, waga, rozmiar, nazwa
['black', 'rectangle', 51, 'small', 'Mars'],
['gold', 'pack', 100, 'big', 'Haribo'],
['purple', 'rectangle', 100, 'big', 'Milka'],
['brown', 'pack', 45, 'small', 'M&M'],
['blue', 'rectangle', 50, 'medium', 'Bounty'],
['blue', 'square', 40, 'small', 'Knoppers'],
['blue', 'rectangle', 35, 'small', 'Milky-way'],
['gold', 'rectangle', 40, 'medium', 'Twix'],
['gold', 'rectangle', 50, 'medium', 'Prince-polo'],
['brown', 'rectangle', 55, 'medium', 'Snickers'],
['brown', 'rectangle', 45, 'medium', 'Lion'],
['white', 'rectangle', 40, 'medium', 'Kinder-bueno'],
['red', 'rectangle', 50, 'medium', 'Kit-kat'],
['blue', 'rectangle', 115, 'big', 'Wedel'],
['white', 'rectangle', 15, 'small', 'Krowka'],
['red', 'pack', 70, 'medium', 'Skittles'],
['orange', 'rectangle', 45, 'medium', 'Reeses'],
['blue', 'rectangle', 55, 'medium', 'Oreo'],
['gold', 'rectangle', 120, 'big', 'Ferrero-rocher'],
['white', 'rectangle', 120, 'big', 'Rafaello'],
['white', 'jar', 600, 'big', 'Nutella'],
['white', 'rectangle', 25, 'small', 'Duplo'],
['brown', 'jar', 500, 'big', 'GoOn'],
['brown', 'jar', 470, 'big', 'Active Orzechowe'],
['red', 'jar', 250, 'medium', 'Strawberry Jam'],
['black', 'jar', 250, 'medium', 'Blackberry Jam'],
['orange', 'jar', 250, 'medium', 'Peach Jam'],
]
=======
return allProducts
def create_data_dict():
products_as_dict = []
sweet = Sweets('Mars', 'czekoladowy', 'baton', 'sredni', 2.49)
products_as_dict.append(vars(sweet))
sweet = Sweets('Mars', 'czekoladowy', 'czekolada', 'duzy', 4.99)
products_as_dict.append(vars(sweet))
sweet = Sweets('Mars', 'czekoladowy', 'czekolada', 'ogromny', 11.26)
products_as_dict.append(vars(sweet))
sweet = Sweets('M&M', 'czekoladowy', 'czekolada', 'duzy', 3.99)
products_as_dict.append(vars(sweet))
sweet = Sweets('M&M', 'czekoladowy', 'baton', 'sredni', 2.89)
products_as_dict.append(vars(sweet))
sweet = Sweets('Nestle', 'bananowy', 'landrynka', 'maly', 0.39)
products_as_dict.append(vars(sweet))
sweet = Sweets('Nestle', 'truskawkowy', 'landrynka', 'maly', 0.39)
products_as_dict.append(vars(sweet))
sweet = Sweets('Nestle', 'cola', 'landrynka', 'maly', 0.49)
products_as_dict.append(vars(sweet))
sweet = Sweets('Wedel', 'czekoladowy', 'baton', 'sredni', 1.99)
products_as_dict.append(vars(sweet))
sweet = Sweets('Maoam', 'truskawkowy', 'guma', 'maly', 0.25)
products_as_dict.append(vars(sweet))
return products_as_dict
>>>>>>> upstream/master

184
decision_tree.py Normal file
View File

@ -0,0 +1,184 @@
import data
training_data = data.learning_data
header = ['color', 'shape', 'weight', 'size', 'name']
# funkcja która zwraca listę unikalnych wartości z każdej kolumny
def uniqie_vals(rows, col):
return set([row[col] for row in rows])
# zliczamy liczbę wystąpień danego typu w zestawie danych
def class_counts(rows):
counts = {} # label -> count
for row in rows:
name = row[-1]
if name not in counts:
counts[name] = 0
counts[name] += 1
return counts
# funkcja do sprawdzania czy wartość jest wartością numeryczną
def is_numeric(val):
return isinstance(val, int) or isinstance(val, float)
# klasa do zadawania pytań
class Question:
def __init__(self, column, value):
self.column = column
self.value = value
def match(self, example):
val = example[self.column]
if is_numeric(val):
return val >= self.value
else:
return val == self.value
def __repr__(self):
condition = '=='
if is_numeric(self.value):
condition = '>='
return "Is %s %s %s?" % (header[self.column], condition, str(self.value))
def partition(rows, question):
""" podział zbioru informacji
dla każdego rzędu w zbiorze, sprawdź czy zgadza się z pytaniem, jeśli tak
dodaj do 'true' inaczej dodaj do 'false' """
true_rows, false_rows = [], []
for row in rows:
if question.match(row):
true_rows.append(row)
else:
false_rows.append(row)
return true_rows, false_rows
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. """
counts = class_counts(rows)
impurity = 1
for lbl in counts:
prob_of_lbl = counts[lbl] / float(len(rows))
impurity -= prob_of_lbl ** 2
return impurity
def info_gain(left, right, current_uncertainty):
p = float(len(left)) / (len(left) + len(right))
return current_uncertainty - p * gini(left) - (1 - p) * gini(right)
def find_best_split(rows):
""" znajdź najlepsze możliwe pytanie do zadania, sprawdzając wszystkie
właściwośći oraz licząc dla nich 'info_gain' """
best_gain = 0
best_question = None
current_uncertainty = gini(rows)
n_features = len(rows[0]) - 1
for col in range(n_features):
values = set([row[col] for row in rows])
for val in values:
question = Question(col, val)
true_rows, false_rows = partition(rows, question)
if len(true_rows) == 0 or len(false_rows) == 0:
continue
gain = info_gain(true_rows, false_rows, current_uncertainty)
if gain > best_gain:
best_gain, best_question = gain, question
return best_gain, best_question
class Leaf:
def __init__(self, rows):
self.predicions = class_counts(rows)
class DecisionNode:
def __init__(self, question, true_branch, false_branch):
self.question = question
self.true_branch = true_branch
self.false_branch = false_branch
def build_tree(rows):
gain, question = find_best_split(rows)
if gain == 0:
return Leaf(rows)
true_rows, false_rows = partition(rows, question)
true_branch = build_tree(true_rows)
false_branch = build_tree(false_rows)
return DecisionNode(question, true_branch, false_branch)
def print_tree(node, spacing=""):
if isinstance(node, Leaf):
print(spacing + "Predict", node.predicions)
else:
print(spacing + str(node.question))
print(spacing + '--> True:')
print_tree(node.true_branch, spacing + " ")
print(spacing + '--> False:')
print_tree(node.false_branch, spacing + " ")
def classify(row, node):
if isinstance(node, Leaf):
return node.predicions
if node.question.match(row):
return classify(row, node.true_branch)
else:
return classify(row, node.false_branch)
def print_leaf(counts):
probs = []
for lbl in counts.keys():
probs.append(lbl)
return probs
# my_tree = build_tree(training_data)
#
# print_tree(my_tree)
#
# testing_data = [
# ['gold', 'rectangle', 50, 'medium', 'Name'],
# ['brown', 'rectangle', 55, 'medium', 'Snickers'],
# ['white', 'rectangle', 120, 'big', 'Name']
# ]
#
# test = ['white', 'rectangle', 120, 'big', 'Name']
#
# # for row in testing_data:
# # print(print_leaf(classify(row, my_tree)))
#
# wynik = print_leaf(classify(test, my_tree))[0]
# print(wynik)

View File

@ -23,6 +23,9 @@ class Field:
self.f = 0
self.previous = None
# Przedmiot, który podnosi agent
self.item = []
# Te rzeczy są potrzebne do wyświetlenia pola
self.image = pygame.image.load('img/Field.png')
self.rect = self.image.get_rect()

28
main.py
View File

@ -2,11 +2,13 @@ import pygame
import functions
import sys
import time
import decision_tree
import data
from agent import Agent
from settings import Settings
from board import create_board, draw_board
from random import randint
from random import randint, choice
# Inicjalizacja programu i utworzenie obiektu ekrany
@ -17,10 +19,11 @@ def run():
pygame.display.set_caption("Inteligentny wózek widłowy")
agent = Agent(screen, 50, 50, "Down")
board = create_board(screen)
my_tree = decision_tree.build_tree(data.learning_data)
for row in board:
for field in row:
print(field.cost_of_travel)
# for row in board:
# for field in row:
# print(field.cost_of_travel)
path = []
next_step = None
@ -41,7 +44,10 @@ def run():
agent.move_forward(board)
print(agent.x, agent.y)
elif event.key == pygame.K_SPACE:
field = board[randint(0, 9)][randint(0, 9)]
board[9][0].item = choice(data.learning_data)
print("Wybrano: " + board[9][0].item[-1])
board[9][0].item[-1] = 'Something'
field = board[9][0]
if not field.is_shelf:
path = functions.a_star(board[agent.y][agent.x], field, board)
path.pop(len(path) - 1)
@ -56,17 +62,19 @@ def run():
next_step = path.pop()
else:
next_step = None
print(next_step, path)
# print(next_step, path)
for row in board:
for field in row:
if not field.is_shelf:
field.image = pygame.image.load('img/Field.png')
for row in board:
for field in row:
print(field.g, field.h, field.f, field.previous)
else:
functions.change_turn(agent, next_step)
print(agent.x, agent.y)
if board[agent.y][agent.x].item:
prediction = decision_tree.print_leaf(decision_tree.classify(board[agent.y][agent.x].item, my_tree))
print("Agent uważa, że przedmiot to: " + prediction[0])
board[agent.y][agent.x].item = []
draw_board(board)
agent.blitme()