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_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)
|
||||
|
||||
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('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
|
||||
"""new_client = {
|
||||
"Wrinkles": random.choice(['Yes', 'No']),
|
||||
@ -83,6 +77,15 @@ def predict_client(client_data,glasses):
|
||||
|
||||
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)))
|
||||
|
||||
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]
|
||||
|
||||
@ -90,5 +93,4 @@ def predict_client(client_data,glasses):
|
||||
#print(new_client_df)
|
||||
#print("Prediction:", prediction[0])
|
||||
|
||||
#graph = graphviz.Source(dot_data)
|
||||
#graph.render("decision_tree", format='png')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user