37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
|
import pickle
|
||
|
|
||
|
|
||
|
def decision(prediction):
|
||
|
if prediction == 0:
|
||
|
return "Nie_podejmuj_działania"
|
||
|
elif prediction == 1:
|
||
|
return "Zastosuj_nawóz"
|
||
|
elif prediction == 2:
|
||
|
return "Zastosuj_środek"
|
||
|
elif prediction == 4:
|
||
|
return "Zbierz"
|
||
|
elif prediction == 5:
|
||
|
return "Roślina_już_zgniła-zbierz_i_wyrzuć"
|
||
|
|
||
|
|
||
|
def test():
|
||
|
for n in range(0, 2):
|
||
|
if n == 0:
|
||
|
print("############# Nie ma nawozu #############")
|
||
|
else:
|
||
|
print("############# Zastosowano nawóz #############")
|
||
|
for s in range(0, 2):
|
||
|
if s == 0:
|
||
|
print("############# Nie ma środka ochrony #############")
|
||
|
else:
|
||
|
print("############# Zastosowano środek ochrony #############")
|
||
|
for st in range(0, 101):
|
||
|
val = tree.predict([[1, n, s, st]])
|
||
|
print("Stan roślinki: ", st, " ", decision(val))
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
filename = 'decisionTree.sav'
|
||
|
tree = pickle.load(open(filename, 'rb'))
|
||
|
test()
|