其他分享
首页 > 其他分享> > 10.5.4 利用sklearn搭建多层神经网络

10.5.4 利用sklearn搭建多层神经网络

作者:互联网

10.5.4 利用sklearn搭建多层神经网络

 

from sklearn.datasets import load_wine
wine=load_wine()
wine.data[0]
wine.data.shape
wine.target_names
wine.feature_names
X=wine.data
y=wine.target
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0)

from sklearn.neural_network import MLPClassifier
model=MLPClassifier(solver="lbfgs",hidden_layer_sizes=(100,))
model.fit(X_train,y_train)
y_predict_on_train=model.predict(X_train)
y_predict_on_test=model.predict(X_test)
from sklearn.metrics import accuracy_score

print('训练集的准确率为:{:.2f}%'.format(100*accuracy_score(y_train,y_predict_on_train)))

print('测试集的准确率为:{:.2f}%'.format(100*accuracy_score(y_test,y_predict_on_test)))

 

标签:10.5,predict,神经网络,train,test,model,sklearn,wine
来源: https://www.cnblogs.com/redufa/p/14424026.html