How do I find which attributes my tree splits on, when using scikit-learn?

前端 未结 3 1196
余生分开走
余生分开走 2020-12-23 02:35

I have been exploring scikit-learn, making decision trees with both entropy and gini splitting criteria, and exploring the differences.

My question, is how can I \"o

3条回答
  •  佛祖请我去吃肉
    2020-12-23 03:02

    If you just want a quick look at which what is going on in the tree, try:

    zip(X.columns[clf.tree_.feature], clf.tree_.threshold, clf.tree_.children_left, clf.tree_.children_right)
    

    where X is the data frame of independent variables and clf is the decision tree object. Notice that clf.tree_.children_left and clf.tree_.children_right together contain the order that the splits were made (each one of these would correspond to an arrow in the graphviz visualization).

提交回复
热议问题