1.数据集
手写字符数据集 DIGITS,该数据集的全称为 Pen-Based Recognition of Handwritten Digits Data Set,来源于 UCI 开放数据集网站。
2.加载数据集
import numpy as np
from sklearn import datasets
digits = datasets.load_digits()
3.分割数据集
from sklearn.model_selection import train_test_split
X, y = digits.data, digits.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=30)
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score
def mpl():
model = MLPClassifier(hidden_layer_sizes=(100, 50), activation=’relu’, solver=’sgd‘, learning_rate_init=0.02, max_iter=100, random_state=1)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
score = accuracy_score(y_test, y_pred)
model = mpl()[0]
plt.plot(model.loss_curve_)
原文地址:https://blog.csdn.net/m0_56366541/article/details/134648006
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_19301.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!