【发布时间】:2021-06-23 03:20:09
【问题描述】:
我可视化了我的决策树分类器,我注意到样本总和错误或公式不同,“值”值与样本值不匹配(屏幕截图)?我是否误解了我的决策树?我想如果在我的节点中有 100 个样本并且 40 个是 True 而 60 个是 False,我会在我的下一个节点中得到 40 个(或 60 个)样本,这些样本再次被划分......
import matplotlib.pyplot as plt
from sklearn import tree
tree1=DecisionTreeClassifier(criterion="entropy",max_features=13,max_leaf_nodes=75,min_impurity_decrease=0.001,min_samples_leaf=12,min_samples_split=20,splitter="best",max_depth=9)
tree1.fit(X_train,y_train)
feature_names=Daten.drop("Abwanderung_LabelEncode",axis=1).columns
class_names=["Keine Abwanderung","Abwanderung"]
fig = plt.figure(figsize=(25,20))
_ = tree.plot_tree(tree1,
feature_names=feature_names,
class_names=class_names,
rounded=True,
filled=True)
【问题讨论】:
标签: python matplotlib scikit-learn decision-tree