手写字符识别神经网络项目总结

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)

  1. 搭建人工神经网络

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)

return model, score

5.绘制损失变化曲线

model = mpl()[0]

plt.plot(model.loss_curve_)

相关推荐
这张生成的图像能检测吗2 分钟前
(论文速读)多任务深度学习框架下基于Lamb波的多损伤数据集构建与量化算法
人工智能·深度学习·算法·数据集·结构健康监测
二川bro4 分钟前
2025年Python机器学习全栈指南:从基础到AI项目部署
人工智能·python·机器学习
梦想的初衷~7 分钟前
“科研创新与智能化转型“暨AI智能体(Agent)开发及与大语言模型的本地化部署、优化技术实践
人工智能·语言模型·自然语言处理·生物信息·材料科学
IT_陈寒33 分钟前
React性能翻倍!90%开发者忽略的5个Hooks最佳实践
前端·人工智能·后端
大任视点34 分钟前
消费电子PCB需求激增,科翔股份发力AI手机终端大周期
人工智能·智能手机
Learn Beyond Limits39 分钟前
Correlation vs Cosine vs Euclidean Distance|相关性vs余弦相似度vs欧氏距离
人工智能·python·神经网络·机器学习·ai·数据挖掘
晨非辰3 小时前
数据结构排序系列指南:从O(n²)到O(n),计数排序如何实现线性时间复杂度
运维·数据结构·c++·人工智能·后端·深度学习·排序算法
2301_812914873 小时前
简单神经网络
人工智能·深度学习·神经网络
koo3644 小时前
pytorch环境配置
人工智能·pytorch·python
模型启动机7 小时前
黄仁勋GTC开场:「AI-XR Scientist」来了!
人工智能·ai·大模型