当前位置:网站首页>机器学习实战-神经网络-21
机器学习实战-神经网络-21
2022-07-28 11:51:00 【gemoumou】
机器学习实战-神经网络-手写数字识别项目
# pip install scikit-learn --upgrade
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import classification_report,confusion_matrix
digits = load_digits()#载入数据
x_data = digits.data #数据
y_data = digits.target #标签
# 标准化
scaler = StandardScaler()
x_data = scaler.fit_transform(x_data)
x_train,x_test,y_train,y_test = train_test_split(x_data,y_data) #分割数据1/4为测试数据,3/4为训练数据
mlp = MLPClassifier(hidden_layer_sizes=(100,50) ,max_iter=500)
mlp.fit(x_train,y_train )

predictions = mlp.predict(x_test)

print(confusion_matrix(y_test,predictions))

机器学习实战-神经网络-葡萄酒分类


import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import classification_report,confusion_matrix
# 载入数据
data = np.genfromtxt("wine_data.csv", delimiter=",")
x_data = data[:,1:]
y_data = data[:,0]
print(x_data.shape)
print(y_data.shape)

# 数据切分
x_train, x_test, y_train, y_test = train_test_split(x_data, y_data)
# 数据标准化
scaler = StandardScaler()
x_train = scaler.fit_transform(x_train)
x_test = scaler.fit_transform(x_test)
# 建模
mlp = MLPClassifier(hidden_layer_sizes=(100,50),max_iter=500)
# 训练
mlp.fit(x_train,y_train)

# 评估
predictions = mlp.predict(x_test)
print(classification_report(y_test,predictions))

print(confusion_matrix(y_test,predictions))

边栏推荐
- 20220728-Object类常用方法
- HMS core audio editing service supports 7 kinds of audio effects to help one-stop audio processing
- IO流再回顾,深入理解序列化和反序列化
- 输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
- 图书馆自动预约脚本
- 快速读入
- 新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
- The input string contains an array of numbers and non characters, such as a123x456. Take the consecutive numbers as an integer, store them in an array in turn, such as 123 in a[0], 456 in a[1], and ou
- 04 pyechars 地理图表(示例代码+效果图)
- 新零售电商O2O模式解析
猜你喜欢

C for循环内定义int i变量出现的重定义问题

Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself

Unity 安装 Device Simulator

Siemens docking Leuze BPS_ 304i notes

Zadig v1.13.0 believes in the power of openness, and workflow connects all values

Developing NES games with C language (cc65) 10. Game cycle

AVL树(平衡搜索树)

洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东

苏黎世联邦理工学院 | 具有可变形注意Transformer 的基于参考的图像超分辨率(ECCV2022))

FlexPro软件:生产、研究和开发中的测量数据分析
随机推荐
AVL tree (balanced search tree)
STM32 loopback structure receives and processes serial port data
LeetCode 42.接雨水
[nuxt 3] (XII) project directory structure 3
利用依赖包直接实现分页、SQL语句
[Nuxt 3] (十二) 项目目录结构 3
[cute new problem solving] climb stairs
第九章 REST 服务安全
leetcode:数组
FlexPro软件:生产、研究和开发中的测量数据分析
Uncover why devaxpress WinForms, an interface control, discards the popular maskbox property
Developing NES game (cc65) 03 and VRAM buffer with C language
MarkDown简明语法手册
Using dependent packages to directly implement paging and SQL statements
Uninstall Navicat: genuine MySQL official client, really fragrant!
Developing NES games with C language (cc65) 10. Game cycle
Multi Chain and multi currency wallet system development cross chain technology
scala 转换、过滤、分组、排序
VS1003 debugging routine
软件架构师必需要了解的 saas 架构设计?