Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 sklearn.tree.DecisionTreeClassifier 时,分类器具有预测概率和类别的方法。
有没有办法使用同一棵树进行聚类:对于给定的输入向量 x,只需告诉 x 属于哪个叶子?
我找到了我自己问题的答案 - 将其留在这里作为下次有人寻找它的参考:
import numpy as np import sklearn.tree clf = sklearn.tree.DecisionTreeClassifier() clf.fit(X,y) clf.tree_.apply(np.asfortranarray(X.astype(sklearn.tree._tree.DTYPE)))