generowanie drzewa decyzyjnego
This commit is contained in:
parent
424794e53e
commit
7309c28361
@ -3,7 +3,8 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/data.csv" beforeDir="false" afterPath="$PROJECT_DIR$/resources/data.csv" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -123,6 +124,13 @@
|
||||
<workItem from="1619363880685" duration="158000" />
|
||||
<workItem from="1621104529134" duration="1090000" />
|
||||
<workItem from="1621107567483" duration="160000" />
|
||||
<workItem from="1621109381657" duration="180000" />
|
||||
<workItem from="1621109567484" duration="55000" />
|
||||
<workItem from="1621109625200" duration="178000" />
|
||||
<workItem from="1621109806483" duration="833000" />
|
||||
<workItem from="1621110649573" duration="32000" />
|
||||
<workItem from="1621110688412" duration="148000" />
|
||||
<workItem from="1621110850717" duration="377000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -130,26 +138,30 @@
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1621109431051">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="628" y="343" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1920.1080@0.0.1920.1080" timestamp="1621109431051" />
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1617994393023">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="690" y="287" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617994393023" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1621107728689">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1621111231927">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1621107728689" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1621107728689">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1621111231927" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1621111231927">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1621107728689" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1621107728689">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1621111231927" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1621111231927">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1621107728689" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1621107728689">
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1621111231927" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1621111231927">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1621107728689" />
|
||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1621111231927" />
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1619289752045">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
@ -166,10 +178,10 @@
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1619289752045" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1621107567058">
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1621110850962">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1621107567058" />
|
||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1621110850962" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
@ -183,6 +195,6 @@
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1621107650440" 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/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1621111175660" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
</component>
|
||||
</project>
|
BIN
__pycache__/treelearn.cpython-37.pyc
Normal file
BIN
__pycache__/treelearn.cpython-37.pyc
Normal file
Binary file not shown.
BIN
mydecisiontree.png
Normal file
BIN
mydecisiontree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
2
py.py
2
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)
|
||||
|
@ -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
|
|
BIN
resources/mydecisiontree.png
Normal file
BIN
resources/mydecisiontree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
20
treelearn.py
Normal file
20
treelearn.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user