cost_complexity_pruning_path(X, y[, …]) 在最小代价复杂度修剪过程中计算修剪路径。...train_test_split(cancer.data,cancer.target,stratify=cancer.target,random_state=42)#stratify:分层
# 构件树,不剪枝
tree = DecisionTreeClassifier...,X_train,y_train,X_test,y_test,title)
print("不剪枝,树的深度:{}".format(tree.get_depth()))
# 构件树,剪枝
tree = DecisionTreeClassifier...wine.data[:,:2]
y = wine.target
X_train,X_test,y_train,y_test = train_test_split(X, y)
clf = DecisionTreeClassifier