自学内容网 自学内容网

1111111

from sklearn.datasets import load_iris

iris=load_iris()

data=iris["data"]

label=iris["target"]

print(len(set(label)))

import matplotlib.pyplot as plt

plt.scatter(data[:,0],data[:,1])

plt.show()

from sklearn.model_selection import train_test_split

x_train,x_test,y_train,y_test=train_test_split(data,label,test_size=0.2)

from sklearn.preprocessing import MinMaxScaler

scaler=MinMaxScaler().fit(x_train)

scaler_x_train=scaler.transform(x_train)

scaler_x_test=scaler.transform(x_test)

from sklearn.tree import DecisionTreeClassifier

model=DecisionTreeClassifier()

model.fit(scaler_x_train,y_train)

from sklearn.metrics import classification_report

pre=model.predict(scaler_x_test)

res=classification_report(y_test,pre)

print(res)


原文地址:https://blog.csdn.net/m0_74921758/article/details/144325919

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!