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

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 分钟前
深度解析 XERJ:为 AI Agent 打造的 Rust 本地搜索引擎
人工智能
天天代码码天天23 分钟前
录下自己的声音,让电脑替你讲故事:我做了一个 C# 离线配音工具
人工智能
Rocky Ding*1 小时前
深入解析GPT-6 Astra提示词工程:从Skills、AGENTS.md到可验证的Agent交付
论文阅读·人工智能·深度学习·机器学习·aigc·ai-native·提示词工程
志尊宝1 小时前
AI原生前端开发(009):AI辅助性能分析与优化建议
人工智能·react.js·ai-native
KeyAction66661 小时前
第二届中国国际人工智能+行动大会看点:智能体专场、算力账本与产品发布
人工智能·ai
johnsong1 小时前
AI前沿日报 2026-10-19:硅基心智觉醒
人工智能
紧跟先前的步伐1 小时前
Go AI Agent 实战 03|Token、上下文窗口与模型调用成本
java·人工智能·golang
老金带你玩AI1 小时前
Taste Skill V2来了,AI做的网站还会一眼认出来吗?
人工智能
方方洛2 小时前
ai-agent教程-18-附录E-推荐阅读与资源
人工智能·llm·agent
const_qiu2 小时前
第四章 00:开篇 —— 从「会聊天」到「记得住、会干活、能协作」
java·开发语言·人工智能·python