zapisywanie drzewa do pliku, zmienienie prędkości głodu
This commit is contained in:
parent
ad6fd4bc1b
commit
dbdb7b6b7d
@ -16,7 +16,7 @@ class Bat(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 35*5
|
||||
minutes_passed = delta.total_seconds() / (25)
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -18,7 +18,7 @@ class Bear(Animal):
|
||||
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 60*5
|
||||
minutes_passed = delta.total_seconds() / (45)
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10 and const.season != "winter":
|
||||
|
@ -22,7 +22,7 @@ class Elephant(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 50*5
|
||||
minutes_passed = delta.total_seconds() / (90)
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Giraffe(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 35*5
|
||||
minutes_passed = delta.total_seconds() / (60)
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -16,7 +16,7 @@ class Owl(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 30*5
|
||||
minutes_passed = delta.total_seconds() / (50)
|
||||
self._starttime = checktime
|
||||
|
||||
if const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Parrot(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 25*5
|
||||
minutes_passed = delta.total_seconds() / (30)
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
@ -17,7 +17,7 @@ class Penguin(Animal):
|
||||
def getting_hungry(self, const):
|
||||
checktime = datetime.now()
|
||||
delta = checktime - self._starttime
|
||||
minutes_passed = delta.total_seconds() / 20*5
|
||||
minutes_passed = delta.total_seconds() / (25)
|
||||
self._starttime = checktime
|
||||
|
||||
if not const.IS_NIGHT and self._feed < 10:
|
||||
|
6
dane.csv
6
dane.csv
@ -9,7 +9,7 @@ False,True,False,summer,2,9.07977,22.08011,20.53507,3
|
||||
False,False,True,winter,11,3.5635,14.75823,43.46342,2
|
||||
False,False,True,winter,9,8.03113,20.6384,30.81177,2
|
||||
True,True,True,summer,0,0.01966,28.27203,3.37575,1
|
||||
False,False,False,autumn,12,8.27518,5.91931,21.10505,3
|
||||
False,False,False,autumn,12,8.27518,5.91931,1.10505,2
|
||||
False,False,True,summer,1,5.058,11.01892,48.04589,3
|
||||
False,True,False,winter,9,5.64777,17.19678,12.20864,1
|
||||
True,True,True,summer,0,6.86046,19.03315,47.13198,3
|
||||
@ -49,7 +49,7 @@ False,False,True,autumn,5,7.85569,40.47073,49.75818,2
|
||||
True,False,True,summer,1,9.03492,23.44692,20.0026,3
|
||||
False,True,True,autumn,8,2.36724,42.81768,21.34668,2
|
||||
False,False,True,summer,15,6.8222,15.2733,15.14799,3
|
||||
True,False,True,summer,4,8.63882,41.36166,17.98981,3
|
||||
True,False,True,summer,4,8.63882,41.36166,7.98981,2
|
||||
False,True,False,autumn,12,0.48943,8.67832,40.4952,1
|
||||
False,False,False,autumn,3,3.0489,14.81219,8.32707,1
|
||||
False,True,True,winter,6,0.41014,49.94757,12.61713,1
|
||||
@ -73,7 +73,7 @@ False,False,False,summer,3,7.36268,28.50462,29.52973,1
|
||||
True,True,True,spring,3,6.1319,37.71758,33.50616,1
|
||||
False,True,True,spring,0,0.77228,42.89976,19.19004,1
|
||||
True,False,True,autumn,3,7.73055,20.87865,37.18248,1
|
||||
False,False,False,summer,1,8.30392,34.47046,34.77926,3
|
||||
False,False,False,summer,1,8.30392,34.47046,8.77926,2
|
||||
True,True,False,summer,8,2.96562,17.50839,23.22476,1
|
||||
True,True,True,winter,4,2.27279,20.58575,32.17293,1
|
||||
True,False,True,spring,7,6.14608,34.46015,17.22245,1
|
||||
|
|
@ -1,5 +1,5 @@
|
||||
import pandas as pd
|
||||
from sklearn.tree import DecisionTreeClassifier, plot_tree, export_graphviz
|
||||
from sklearn.tree import DecisionTreeClassifier, plot_tree
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.metrics import accuracy_score
|
||||
import matplotlib.pyplot as plt
|
||||
@ -9,24 +9,22 @@ data = pd.read_csv('dane.csv', header=0)
|
||||
X = data[headers]
|
||||
Y = data['decision']
|
||||
X = pd.get_dummies(data=X, columns=['season'])
|
||||
clf = DecisionTreeClassifier(random_state=0, min_samples_leaf = 4, min_samples_split=2)
|
||||
clf = clf.fit(X,Y)
|
||||
#skuteczność drzewa
|
||||
'''
|
||||
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, train_size=0.8)
|
||||
clf = clf.fit(X_train, Y_train)
|
||||
Y_pred = clf.predict(X_test)
|
||||
accuracy = accuracy_score(Y_test, Y_pred)
|
||||
clf = DecisionTreeClassifier(max_depth=6)
|
||||
X1, X2, Y1, Y2 = train_test_split(X, Y, train_size=0.8)
|
||||
clf = clf.fit(X1, Y1)
|
||||
pred = clf.predict(X2)
|
||||
accuracy = accuracy_score(Y2, pred)
|
||||
print("Dokładność:", accuracy)
|
||||
'''
|
||||
|
||||
|
||||
|
||||
#zapisanie drzewa do pliku
|
||||
plt.figure(figsize=(50,30))
|
||||
plot_tree(clf, filled=True, feature_names=X.columns, class_names=['nie karmi', 'karmi mokrą karmą', 'karmi suchą karmą'])
|
||||
|
||||
plot_tree(clf, filled=True, feature_names=X.columns.tolist(), class_names=['nie karmi', 'karmi mokrą karmą', 'karmi suchą karmą'])
|
||||
plt.savefig('tree.png')
|
||||
# dane do decyzji
|
||||
def feed_decision(adult,active_time,ill,season,guests,hunger,dry_food,wet_food):
|
||||
|
||||
X_new = pd.DataFrame({
|
||||
'adult': [adult],
|
||||
'active_time': [active_time],
|
||||
|
Loading…
Reference in New Issue
Block a user