最近搜索
暂无搜索记录
热搜
JAVA
大数据
分布式
Python
人工智能
爬虫
WEB
JavaScript
认证
参照老师代码写的,但是结果却不一样,我的根节点是是petal length。请老师帮忙看看哪里错了
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn import datasets
import graphviz
from sklearn.model_selection import train_test_split
from sklearn import tree
iris=datasets.load_iris()
X=iris['data']
y=iris['target']
feature_names=iris['feature_names']
print(feature_names)
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=256)
model=DecisionTreeClassifier()
model.fit(X_train,y_train)
print('测试数据得分为',model.score(X_test,y_test))
print('算法预测的结果:',model.predict(X_test))
print('真实结果为',y_test)
#逻辑斯蒂回归中手动计算过概率
model.predict_proba(X_test)
dot_data=tree.export_graphviz(model,filled=True,rounded=True,feature_names=feature_names)
graph=graphviz.Source(dot_data)
graph.view()