3
私の目標は、デシジョンツリー内でどのような深さで2つのサンプルが分かれるかを特定することです。 scikit学習の開発バージョンでは、共通ノードを最後に識別するためにdecision_path()
メソッドを使用することができます。scikit-learnデシジョンツリーノードの深さ
from sklearn import tree
import numpy as np
clf = tree.DecisionTreeClassifier()
clf.fit(data, outcomes)
n_nodes = clf.tree_.node_count
node_indicator = clf.decision_path(data).toarray()
sample_ids = [0,1]
common_nodes = (node_indicator[sample_ids].sum(axis=0) == len(sample_ids))
common_node_id = np.arange(n_nodes)[common_nodes]
max_node = np.max(common_node_id)
はmax_node
はおそらくclf.tree_.children_right
とclf.tree_.chrildren_left
で、ツリー内の何が起こるかの深さで判別する方法はありますか?ここで