add graphviz to predict client
This commit is contained in:
parent
a2b1a1e4c0
commit
cf186c2ef1
@ -34,7 +34,7 @@ X_test = encoder.transform(X_test)
|
|||||||
|
|
||||||
#print(X_train.head())
|
#print(X_train.head())
|
||||||
#print(X_test.head())
|
#print(X_test.head())
|
||||||
clf_en = DecisionTreeClassifier(criterion='entropy', max_depth=3, random_state=0)
|
clf_en = DecisionTreeClassifier(criterion='entropy', max_depth=200, random_state=0)
|
||||||
clf_en.fit(X_train, y_train)
|
clf_en.fit(X_train, y_train)
|
||||||
|
|
||||||
y_pred_en = clf_en.predict(X_test)
|
y_pred_en = clf_en.predict(X_test)
|
||||||
@ -46,12 +46,6 @@ y_pred_train_en = clf_en.predict(X_train)
|
|||||||
#print('Training set score: {:.4f}'.format(clf_en.score(X_train, y_train)))
|
#print('Training set score: {:.4f}'.format(clf_en.score(X_train, y_train)))
|
||||||
#print('Test set score: {:.4f}'.format(clf_en.score(X_test, y_test)))
|
#print('Test set score: {:.4f}'.format(clf_en.score(X_test, y_test)))
|
||||||
|
|
||||||
dot_data = tree.export_graphviz(clf_en, out_file=None,
|
|
||||||
feature_names=X_train.columns,
|
|
||||||
class_names=y_train.unique(),
|
|
||||||
filled=True, rounded=True,
|
|
||||||
special_characters=True)
|
|
||||||
|
|
||||||
#nowy klient testowo
|
#nowy klient testowo
|
||||||
"""new_client = {
|
"""new_client = {
|
||||||
"Wrinkles": random.choice(['Yes', 'No']),
|
"Wrinkles": random.choice(['Yes', 'No']),
|
||||||
@ -84,11 +78,19 @@ def predict_client(client_data,glasses):
|
|||||||
print('Training set score: {:.4f}'.format(clf_en.score(X_train, y_train)))
|
print('Training set score: {:.4f}'.format(clf_en.score(X_train, y_train)))
|
||||||
print('Test set score: {:.4f}'.format(clf_en.score(X_test, y_test)))
|
print('Test set score: {:.4f}'.format(clf_en.score(X_test, y_test)))
|
||||||
|
|
||||||
|
dot_data = tree.export_graphviz(clf_en, out_file=None,
|
||||||
|
feature_names=X_train.columns,
|
||||||
|
class_names=y_train.unique(),
|
||||||
|
filled=True, rounded=True,
|
||||||
|
special_characters=True)
|
||||||
|
|
||||||
|
graph = graphviz.Source(dot_data)
|
||||||
|
graph.render("decision_tree", format='png')
|
||||||
|
|
||||||
return prediction[0]
|
return prediction[0]
|
||||||
|
|
||||||
#print("\nNew client:")
|
#print("\nNew client:")
|
||||||
#print(new_client_df)
|
#print(new_client_df)
|
||||||
#print("Prediction:", prediction[0])
|
#print("Prediction:", prediction[0])
|
||||||
|
|
||||||
#graph = graphviz.Source(dot_data)
|
|
||||||
#graph.render("decision_tree", format='png')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user