Repaired prediction, changed dataset

This commit is contained in:
trzmielewskiR 2022-05-12 09:39:25 +02:00
parent 42d09e21f8
commit 7add741845
5 changed files with 239 additions and 54 deletions

View File

@ -11,11 +11,10 @@ time_since_flush = [1,2,3,4,5,6,7,8,9,10]
type_of_trash = {"bio":1, "szklo":2, "plastik":3, "papier":4, "mieszane":5} type_of_trash = {"bio":1, "szklo":2, "plastik":3, "papier":4, "mieszane":5}
access_to_bin = { "no":1, "yes":2} access_to_bin = { "no":1, "yes":2}
distance = [1,2,3,4,5,6,7,8,9,10] distance = [1,2,3,4,5,6,7,8,9,10]
decision = [1,2,3,4,5] decision = [0,1] - decyzje zostaną zmienione z tych z wagami na zero jedynkowe ze względu na pewne trudności w dalszej pracy
''' '''
decisions = ["decision"] decisions = ["decision"]
attributes = ["season", "enough_space_in_trashmaster", "time_since_flush", "type_of_trash", "access_to_bin", "distance", attributes = ["season", "enough_space_in_trashmaster", "time_since_flush", "type_of_trash", "access_to_bin", "distance"]
"decision"]
# return tree made from attributes # return tree made from attributes
@ -60,6 +59,10 @@ def tree_to_png(decision_tree):
def tree_to_structure(decision_tree): def tree_to_structure(decision_tree):
joblib.dump(decision_tree, './decision_tree/tree_model') joblib.dump(decision_tree, './decision_tree/tree_model')
def tree_from_structure(file):
return joblib.load(file)
#drzewo = tree() #drzewo = tree()
#tree_as_txt(drzewo) #tree_as_txt(drzewo)
#tree_to_png(drzewo) #tree_to_png(drzewo)

View File

@ -2,30 +2,30 @@ season,enough_space_in_trashmaster,time_since_flush,type_of_trash,access_to_bin,
2,2,1,1,2,10,1 2,2,1,1,2,10,1
2,2,2,2,2,8,1 2,2,2,2,2,8,1
2,2,3,3,2,6,1 2,2,3,3,2,6,1
2,2,4,4,2,4,2 2,2,4,4,2,4,0
2,2,5,5,2,2,3 2,2,5,5,2,2,0
2,2,6,1,2,1,5 2,2,6,1,2,1,1
2,2,7,2,2,3,4 2,2,7,2,2,3,1
2,2,8,3,2,5,4 2,2,8,3,2,5,0
2,2,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5 1
115 4 2 4 4 2 6 1
116 4 2 5 5 2 4 1
117 4 2 6 1 2 5 1
118 4 2 7 2 2 6 1
119 4 2 8 3 2 7 1
120 4 2 9 4 2 8 1
121 4 2 10 5 2 10 1
122 4 2 1 1 2 6 1
123 4 2 7 2 2 3 1
124 4 2 8 3 2 5 1
125 4 2 9 4 2 7 1
126 4 2 10 5 2 9 1
127 4 2 1 1 2 2 1
128 4 2 7 2 1 1 0
129 4 2 8 3 1 9 0
130 4 2 9 4 1 8 0
131 4 2 10 5 1 7 0
132 4 2 1 1 1 3 0
133 4 2 2 2 1 2 0
134 4 2 3 3 1 1 0
135 4 2 4 4 1 4 0
136 4 2 5 5 1 5 0
137 4 2 6 1 1 6 0
138 4 2 7 2 1 10 0
139 4 2 8 3 1 9 0
140 4 2 9 4 1 8 0
141 4 2 10 5 1 7 0
142 4 2 1 1 1 2 0
143 4 2 2 2 1 4 0
144 4 2 3 3 1 6 0
145 4 2 4 4 1 8 0
146 4 2 5 5 2 10 1
147 4 2 6 1 2 1 1
148 4 1 2 2 2 5 1
149 4 1 3 3 2 4 1
150 4 1 4 4 1 3 0
151 4 1 5 5 1 2 0
152 4 1 6 1 1 1 0
153 1 2 2 2 2 1 1
154 1 2 3 3 2 4 1
155 1 2 4 4 2 3 1
156 1 2 5 5 2 6 1
157 1 2 6 1 2 5 1
158 1 2 7 2 2 8 1
159 1 2 8 3 2 7 1
160 1 2 9 4 2 9 1
161 1 2 10 5 2 10 1
162 1 2 1 1 2 7 1
163 1 2 2 2 2 6 1
164 1 2 3 3 2 4 0
165 1 2 4 4 2 1 1
166 1 2 5 5 2 2 1
167 1 2 6 1 2 3 1
168 1 2 7 2 2 9 1
169 1 2 8 3 2 8 0
170 1 2 9 4 2 5 1
171 1 2 10 5 2 4 1
172 1 2 1 1 2 1 1
173 1 2 2 2 1 7 0
174 1 2 3 3 1 9 0
175 1 2 4 4 1 10 0
176 1 2 5 5 1 3 0
177 1 2 6 1 1 2 0
178 1 2 7 2 1 5 0
179 1 2 8 3 1 6 0
180 1 2 9 4 1 8 0
181 1 2 10 5 1 3 0
182 1 2 1 1 1 1 0
183 1 2 2 2 1 2 0
184 1 2 3 3 1 6 0
185 1 2 4 4 1 9 0
186 1 2 5 5 1 7 0
187 1 2 6 1 1 4 0
188 1 2 7 2 1 3 0
189 1 2 8 3 1 5 0
190 1 2 9 4 1 10 0
191 1 2 10 5 1 8 0
192 1 2 1 1 2 2 1
193 1 1 2 2 2 4 0
194 1 1 3 3 2 6 0
195 1 1 4 4 2 7 0
196 1 1 5 5 2 1 0
197 1 1 6 1 2 9 0
198 1 1 7 2 2 3 0
199 1 1 8 3 2 9 0
200 1 1 9 4 2 9 0
201 1 1 10 5 2 1 0

View File

@ -1,16 +1,94 @@
|--- feature_6 <= 0.50 |--- feature_4 <= 1.50
| |--- class: 0 | |--- feature_5 <= 1.50
|--- feature_6 > 0.50 | | |--- feature_2 <= 6.50
| |--- feature_6 <= 1.50 | | | |--- class: 0
| | |--- class: 1 | | |--- feature_2 > 6.50
| |--- feature_6 > 1.50 | | | |--- feature_0 <= 3.00
| | |--- feature_6 <= 3.50 | | | | |--- class: 1
| | | |--- feature_6 <= 2.50 | | | |--- feature_0 > 3.00
| | | | |--- class: 2 | | | | |--- class: 0
| | | |--- feature_6 > 2.50 | |--- feature_5 > 1.50
| | | | |--- class: 3 | | |--- class: 0
| | |--- feature_6 > 3.50 |--- feature_4 > 1.50
| | | |--- feature_6 <= 4.50 | |--- feature_1 <= 1.50
| | | | |--- class: 4 | | |--- feature_0 <= 3.50
| | | |--- feature_6 > 4.50 | | | |--- class: 0
| | | | |--- class: 5 | | |--- feature_0 > 3.50
| | | |--- class: 1
| |--- feature_1 > 1.50
| | |--- feature_0 <= 3.50
| | | |--- feature_0 <= 1.50
| | | | |--- feature_3 <= 2.50
| | | | | |--- class: 1
| | | | |--- feature_3 > 2.50
| | | | | |--- feature_3 <= 3.50
| | | | | | |--- feature_5 <= 7.50
| | | | | | | |--- feature_2 <= 5.50
| | | | | | | | |--- class: 0
| | | | | | | |--- feature_2 > 5.50
| | | | | | | | |--- class: 1
| | | | | | |--- feature_5 > 7.50
| | | | | | | |--- class: 0
| | | | | |--- feature_3 > 3.50
| | | | | | |--- class: 1
| | | |--- feature_0 > 1.50
| | | | |--- feature_3 <= 1.50
| | | | | |--- feature_5 <= 2.50
| | | | | | |--- feature_5 <= 1.50
| | | | | | | |--- class: 1
| | | | | | |--- feature_5 > 1.50
| | | | | | | |--- feature_0 <= 2.50
| | | | | | | | |--- class: 0
| | | | | | | |--- feature_0 > 2.50
| | | | | | | | |--- class: 1
| | | | | |--- feature_5 > 2.50
| | | | | | |--- class: 1
| | | | |--- feature_3 > 1.50
| | | | | |--- feature_2 <= 3.50
| | | | | | |--- feature_0 <= 2.50
| | | | | | | |--- feature_5 <= 2.00
| | | | | | | | |--- class: 1
| | | | | | | |--- feature_5 > 2.00
| | | | | | | | |--- feature_5 <= 4.00
| | | | | | | | | |--- class: 0
| | | | | | | | |--- feature_5 > 4.00
| | | | | | | | | |--- feature_3 <= 2.50
| | | | | | | | | | |--- feature_5 <= 7.00
| | | | | | | | | | | |--- class: 0
| | | | | | | | | | |--- feature_5 > 7.00
| | | | | | | | | | | |--- class: 1
| | | | | | | | | |--- feature_3 > 2.50
| | | | | | | | | | |--- class: 1
| | | | | | |--- feature_0 > 2.50
| | | | | | | |--- class: 1
| | | | | |--- feature_2 > 3.50
| | | | | | |--- feature_5 <= 1.50
| | | | | | | |--- class: 0
| | | | | | |--- feature_5 > 1.50
| | | | | | | |--- feature_3 <= 2.50
| | | | | | | | |--- feature_5 <= 5.00
| | | | | | | | | |--- class: 1
| | | | | | | | |--- feature_5 > 5.00
| | | | | | | | | |--- class: 0
| | | | | | | |--- feature_3 > 2.50
| | | | | | | | |--- feature_5 <= 5.50
| | | | | | | | | |--- feature_0 <= 2.50
| | | | | | | | | | |--- feature_2 <= 4.50
| | | | | | | | | | | |--- class: 0
| | | | | | | | | | |--- feature_2 > 4.50
| | | | | | | | | | | |--- class: 0
| | | | | | | | | |--- feature_0 > 2.50
| | | | | | | | | | |--- feature_2 <= 4.50
| | | | | | | | | | | |--- class: 0
| | | | | | | | | | |--- feature_2 > 4.50
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | |--- feature_5 > 5.50
| | | | | | | | | |--- feature_5 <= 6.50
| | | | | | | | | | |--- class: 1
| | | | | | | | | |--- feature_5 > 6.50
| | | | | | | | | | |--- feature_2 <= 8.50
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | | |--- feature_2 > 8.50
| | | | | | | | | | | |--- truncated branch of depth 4
| | |--- feature_0 > 3.50
| | | |--- class: 1

Binary file not shown.

View File

@ -20,6 +20,10 @@ def printTree():
decisionTree.tree_as_txt(tree) decisionTree.tree_as_txt(tree)
decisionTree.tree_to_png(tree) decisionTree.tree_to_png(tree)
decisionTree.tree_to_structure(tree) decisionTree.tree_to_structure(tree)
drzewo = decisionTree.tree_from_structure('./decision_tree/tree_model')
print("Dla losowych danych predykcja czy wziąć kosz to: ")
dec = decisionTree.decision(drzewo, 4, 2, 7, 4, 2, 3)
print(dec)
class Game(): class Game():