diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1cc051e..19cbc3c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,7 +3,8 @@
-
+
+
@@ -123,6 +124,13 @@
+
+
+
+
+
+
+
@@ -130,26 +138,30 @@
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -166,10 +178,10 @@
-
+
-
+
@@ -183,6 +195,6 @@
-
+
\ No newline at end of file
diff --git a/__pycache__/treelearn.cpython-37.pyc b/__pycache__/treelearn.cpython-37.pyc
new file mode 100644
index 0000000..deabdf5
Binary files /dev/null and b/__pycache__/treelearn.cpython-37.pyc differ
diff --git a/mydecisiontree.png b/mydecisiontree.png
new file mode 100644
index 0000000..4e0db11
Binary files /dev/null and b/mydecisiontree.png differ
diff --git a/py.py b/py.py
index 7a17ea3..311c600 100644
--- a/py.py
+++ b/py.py
@@ -5,6 +5,7 @@ import map
import plant
import pygame
import station
+import treelearn
import tractor
pygame.display.set_caption("Smart Tractor")
def main():
@@ -19,6 +20,7 @@ def main():
tractor1 = tractor.Tractor(amount_of_seeds_dict, collected_plants_dict, definitions.TRACTOR_DIRECTION_NORTH, fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL, 0, 0)
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
clock = pygame.time.Clock()
+ treelearn.treelearn()
run = True
while run: #pętla główna programu
clock.tick(definitions.FPS)
diff --git a/resources/data.csv b/resources/data.csv
index ce441eb..902a053 100644
--- a/resources/data.csv
+++ b/resources/data.csv
@@ -1,101 +1,101 @@
-#;amount of seeds;collected plants;fertilizer;fuel;water level;back to station
-1;10;79;8;129;12;1
-2;39;195;8;125;1;1
-3;68;5;5;2;3;1
-4;30;70;4;162;24;0
-5;49;121;0;158;37;0
-6;62;139;4;112;9;0
-7;24;154;4;138;14;1
-8;45;151;3;68;4;1
-9;44;96;0;2;30;1
-10;78;17;6;146;24;0
-11;38;170;3;91;9;1
-12;40;85;3;40;4;1
-13;47;38;0;54;32;0
-14;36;179;6;77;31;1
-15;3;22;6;73;23;1
-16;4;46;3;160;17;1
-17;48;27;8;43;0;1
-18;9;16;1;164;12;1
-19;9;14;0;19;3;1
-20;48;126;0;68;21;0
-21;35;185;7;81;3;1
-22;75;21;8;153;6;1
-23;32;136;5;91;23;0
-24;47;167;7;123;17;0
-25;76;32;3;114;35;0
-26;80;60;6;5;0;1
-27;40;15;1;50;24;0
-28;62;3;6;6;21;1
-29;10;159;8;199;24;1
-30;8;149;2;49;1;1
-31;76;55;1;45;3;1
-32;3;29;5;111;8;1
-33;15;14;7;118;7;1
-34;56;112;4;87;30;0
-35;1;168;4;40;27;1
-36;65;149;4;40;34;0
-37;21;190;4;82;17;1
-38;66;83;1;155;6;1
-39;19;165;7;3;2;1
-40;38;92;3;2;16;1
-41;18;141;0;6;11;1
-42;30;192;6;85;20;1
-43;54;30;0;172;30;0
-44;66;25;0;79;4;1
-45;43;142;1;29;9;1
-46;0;48;0;58;32;1
-47;6;105;1;83;13;1
-48;22;175;7;117;24;1
-49;31;95;3;146;30;0
-50;72;64;0;33;23;0
-51;41;113;87;31;31;0
-52;45;54;4;87;9;1
-53;39;107;5;200;1;1
-54;38;167;6;112;32;0
-55;63;103;0;56;18;0
-56;73;66;8;36;10;1
-57;3;67;1;174;10;1
-58;59;182;8;4;12;1
-59;72;24;4;60;17;0
-60;26;3;4;67;35;0
-61;66;153;5;19;9;1
-62;74;155;5;86;13;1
-63;75;71;8;179;9;1
-64;67;101;3;65;38;0
-65;46;192;6;39;4;1
-66;58;109;7;11;3;1
-67;25;30;0;156;37;0
-68;25;115;1;150;7;1
-69;38;195;3;185;12;1
-70;39;41;5;168;32;0
-71;45;163;1;98;32;1
-72;18;107;0;150;39;0
-73;72;131;1;188;6;1
-74;64;134;3;121;28;0
-75;76;193;5;181;35;1
-76;42;151;4;8;40;1
-77;32;95;1;185;40;0
-78;31;106;4;30;14;0
-79;75;37;7;175;0;1
-80;58;70;0;163;36;0
-81;74;112;6;133;7;1
-82;46;72;0;175;35;0
-83;42;68;6;188;3;1
-84;1;127;5;16;13;1
-85;16;38;8;92;15;0
-86;22;82;3;69;29;0
-87;17;68;4;0;5;1
-88;22;172;4;11;17;1
-89;14;115;5;67;20;0
-90;18;29;7;135;20;0
-91;52;140;7;20;39;1
-92;0;139;5;49;35;1
-93;31;170;6;93;26;1
-94;56;78;4;47;10;1
-95;71;6;1;116;3;1
-96;11;61;3;39;27;0
-97;73;152;8;126;1;1
-98;21;57;4;0;29;1
-99;68;6;3;170;38;0
-100;13;38;0;50;34;0
+amount of seeds,collected plants,fertilizer,fuel,water level,back to station
+10,79,8,129,12,1
+39,195,8,125,1,1
+68,5,5,2,3,1
+30,70,4,162,24,0
+49,121,0,158,37,0
+62,139,4,112,9,0
+24,154,4,138,14,1
+45,151,3,68,4,1
+44,96,0,2,30,1
+78,17,6,146,24,0
+38,170,3,91,9,1
+40,85,3,40,4,1
+47,38,0,54,32,0
+36,179,6,77,31,1
+3,22,6,73,23,1
+4,46,3,160,17,1
+48,27,8,43,0,1
+9,16,1,164,12,1
+9,14,0,19,3,1
+48,126,0,68,21,0
+35,185,7,81,3,1
+75,21,8,153,6,1
+32,136,5,91,23,0
+47,167,7,123,17,0
+76,32,3,114,35,0
+80,60,6,5,0,1
+40,15,1,50,24,0
+62,3,6,6,21,1
+10,159,8,199,24,1
+8,149,2,49,1,1
+76,55,1,45,3,1
+3,29,5,111,8,1
+15,14,7,118,7,1
+56,112,4,87,30,0
+1,168,4,40,27,1
+65,149,4,40,34,0
+21,190,4,82,17,1
+66,83,1,155,6,1
+19,165,7,3,2,1
+38,92,3,2,16,1
+18,141,0,6,11,1
+30,192,6,85,20,1
+54,30,0,172,30,0
+66,25,0,79,4,1
+43,142,1,29,9,1
+0,48,0,58,32,1
+6,105,1,83,13,1
+22,175,7,117,24,1
+31,95,3,146,30,0
+72,64,0,33,23,0
+41,113,87,31,31,0
+45,54,4,87,9,1
+39,107,5,200,1,1
+38,167,6,112,32,0
+63,103,0,56,18,0
+73,66,8,36,10,1
+3,67,1,174,10,1
+59,182,8,4,12,1
+72,24,4,60,17,0
+26,3,4,67,35,0
+66,153,5,19,9,1
+74,155,5,86,13,1
+75,71,8,179,9,1
+67,101,3,65,38,0
+46,192,6,39,4,1
+58,109,7,11,3,1
+25,30,0,156,37,0
+25,115,1,150,7,1
+38,195,3,185,12,1
+39,41,5,168,32,0
+45,163,1,98,32,1
+18,107,0,150,39,0
+72,131,1,188,6,1
+64,134,3,121,28,0
+76,193,5,181,35,1
+42,151,4,8,40,1
+32,95,1,185,40,0
+31,106,4,30,14,0
+75,37,7,175,0,1
+58,70,0,163,36,0
+74,112,6,133,7,1
+46,72,0,175,35,0
+42,68,6,188,3,1
+1,127,5,16,13,1
+16,38,8,92,15,0
+22,82,3,69,29,0
+17,68,4,0,5,1
+22,172,4,11,17,1
+14,115,5,67,20,0
+18,29,7,135,20,0
+52,140,7,20,39,1
+0,139,5,49,35,1
+31,170,6,93,26,1
+56,78,4,47,10,1
+71,6,1,116,3,1
+11,61,3,39,27,0
+73,152,8,126,1,1
+21,57,4,0,29,1
+68,6,3,170,38,0
+13,38,0,50,34,0
\ No newline at end of file
diff --git a/resources/mydecisiontree.png b/resources/mydecisiontree.png
new file mode 100644
index 0000000..4e0db11
Binary files /dev/null and b/resources/mydecisiontree.png differ
diff --git a/treelearn.py b/treelearn.py
new file mode 100644
index 0000000..fc0104e
--- /dev/null
+++ b/treelearn.py
@@ -0,0 +1,20 @@
+import matplotlib.image as pltimg
+import matplotlib.pyplot as plt
+import os
+import pandas
+import pydotplus
+from sklearn import tree
+from sklearn.tree import DecisionTreeClassifier
+def treelearn():
+ df = pandas.read_csv(os.path.join('resources', 'data.csv'))
+ features = ['amount of seeds', 'collected plants', 'fertilizer', 'fuel', 'water level']
+ x = df[features]
+ y = df['back to station']
+ dtree = DecisionTreeClassifier()
+ dtree = dtree.fit(x, y)
+ data = tree.export_graphviz(dtree, out_file=None, feature_names=features)
+ graph = pydotplus.graph_from_dot_data(data)
+ graph.write_png(os.path.join('resources', 'mydecisiontree.png'))
+ img = pltimg.imread('mydecisiontree.png')
+ imgplot = plt.imshow(img)
+ plt.show()
\ No newline at end of file