How a Classification Tree Algorithm Splits Feature By Groups

Alex Kataev
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:
X-values, features
  • labels:
y-values, labels

And the diagram with a classification tree and steps clarification:

How decision tree works, by Alex Kataev at https://medium.com/@alexkataev

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 😉👍

--

--

Alex Kataev
Alex Kataev

Written by Alex Kataev

Software Engineering & Data Science Enthusiast

No responses yet