Zaktualizuj 'injectCode.py'
This commit is contained in:
parent
525ec6cde1
commit
9c3d698f05
@ -1,33 +1,33 @@
|
|||||||
import pickle
|
import pickle
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def prediction(warzywo, nawoz ,srodek, stan_wzrostu):
|
def prediction(warzywo, nawoz ,srodek, stan_wzrostu):
|
||||||
filename = 'pliki/decisionTree.sav'
|
filename = 'decisionTree.sav'
|
||||||
tree = pickle.load(open(filename, 'rb'))
|
tree = pickle.load(open(filename, 'rb'))
|
||||||
val = (tree.predict([[warzywo, nawoz, srodek, stan_wzrostu]]))
|
val = (tree.predict([[warzywo, nawoz, srodek, stan_wzrostu]]))
|
||||||
save(val)
|
save(val)
|
||||||
|
|
||||||
def save(prediction):
|
def save(prediction):
|
||||||
pred = str(prediction)
|
pred = str(prediction)
|
||||||
plik = open('pliki/dec.txt', 'w')
|
plik = open('dec.txt', 'w')
|
||||||
plik.write(pred[1])
|
plik.write(pred[1])
|
||||||
plik.close()
|
plik.close()
|
||||||
|
|
||||||
def decision(prediction):
|
def decision(prediction):
|
||||||
if prediction == 0:
|
if prediction == 0:
|
||||||
return "Nie_podejmuj_dzialania"
|
return "Nie_podejmuj_dzialania"
|
||||||
elif prediction == 1:
|
elif prediction == 1:
|
||||||
return "Zastosuj_nawoz"
|
return "Zastosuj_nawoz"
|
||||||
elif prediction == 2:
|
elif prediction == 2:
|
||||||
return "Zastosuj_srodek"
|
return "Zastosuj_srodek"
|
||||||
elif prediction == 4:
|
elif prediction == 4:
|
||||||
return "Zbierz"
|
return "Zbierz"
|
||||||
elif prediction == 5:
|
elif prediction == 5:
|
||||||
return "Roslina_juz_zgnila__zbierz_i_wyrzuc"
|
return "Roslina_juz_zgnila__zbierz_i_wyrzuc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Map command line arguments to function arguments.
|
# Map command line arguments to function arguments.
|
||||||
prediction(*sys.argv[1:])
|
prediction(*sys.argv[1:])
|
Loading…
Reference in New Issue
Block a user