Created
November 27, 2018 09:19
-
-
Save kaskichandrakant/fe92c48df247eb3a6daadb7ab4f6f18d to your computer and use it in GitHub Desktop.
This file contains 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
import pandas as pd | |
from sklearn import tree,model_selection | |
df = pd.read_csv('path/to/csv') | |
target = df["target_column_name"].values | |
feature_names = ['columns','with','which','decision','is','to','be','made'] | |
features = df[feature_names].values | |
visual_tree = tree.DecisionTreeClassifier(random_state=1 | |
,max_depth=10, | |
min_samples_split=2) | |
visual_tree_=visual_tree.fit(features,target) | |
tree.export_graphviz(visual_tree_,feature_names = feature_names,out_file='tree.dot') | |
#convert this dot file to png using [dot -Tpng tree.dot -o new_tree.png] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment