How a Classification Tree Algorithm Splits Feature By Groups
2 min readNov 27, 2020
Based on an assignment #3 by ODS (Open Data Science Community) (https://www.kaggle.com/kashnitsky/a3-demo-decision-trees).
I’ve created an easy-to-read diagram of how a classification tree works with DataFrame features — how an algorithm splits every feature by groups while constructing the classification tree. Hope this diagram will make some things clearer.
Now, just for reference:
- train data:
- labels:
And the diagram with a classification tree and steps clarification:
What tools I’ve used:
sklearn.tree.DecisionTreeClassifier() # for fit and predict# Export a decision tree in DOT format for pydotplus
sklearn.tree.export_graphviz()# For creating png image of the tree
pydotplus.graph_from_dot_data()
If you have any questions — welcome to the comment section below.
Cheers.
Thank you for your time! 🎉
Follow me for more interesting topics 😉👍