DecisionTreeClassifier.tree_.n_node_samples is the total number of samples in all classes of one node, and DecisionTreeClassifier.tree_.value is the computed weight for each class of one node. Only if the sample_weight and class_weight of this DecisionTreeClassifier is one, then this attribute equals the number of samples of each class of one node.
But for the general case with a given sample_weight and class_weight, is there any attribute telling us the number of samples of each class within one node? import pandas as pd from sklearn.datasets import load_iris from sklearn import tree import sklearn iris = sklearn.datasets.load_iris() clf = tree.DecisionTreeClassifier(class_weight={0 : 0.30, 1: 0.3, 2:0.4}, max_features="auto") clf.fit(iris.data, iris.target) # the total number of samples in all classes of each node clf.tree_.n_node_samples # the computed weight for each class of each node clf.tree_.value
------------------------------------------------------------------------------
_______________________________________________ Scikit-learn-general mailing list Scikit-learn-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scikit-learn-general