Created
May 19, 2019 17:31
-
-
Save netsatsawat/aeb60e7b99b3ae0868a67e2030a98b7d to your computer and use it in GitHub Desktop.
Code snippet for decision tree and plot the decision tree to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tree_clf = tree.DecisionTreeClassifier(random_state=SEED, max_depth=3) | |
_ = myUtilityFunction.prediction_evaluation(tree_clf, X_train, X_test, | |
y_train, y_test, X_train.columns, | |
'features') | |
dot_data = tree.export_graphviz(tree_clf, out_file=None, | |
feature_names=X_train.columns, | |
class_names=['No', 'Yes'], | |
filled=True, rounded=True, | |
special_characters=True) | |
graph = graphviz.Source(dot_data) | |
graph.format = 'png' | |
graph.render('../img/output/model_decision tree_employee attrition', view=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment