支持向量机-手写数字识别
来源:互联网 发布:linux循环执行命令 编辑:程序博客网 时间:2024/04/28 13:26
Python源码
#coding=utf-8from sklearn.datasets import load_digits#-------------from sklearn.cross_validation import train_test_split#-------------#load data standardize modelfrom sklearn.preprocessing import StandardScaler#load SVM:LinearSVC which is based on Linear hypothesisfrom sklearn.svm import LinearSVC#-------------from sklearn.metrics import classification_report#------------- store handwrite num datas on digitsdigits=load_digits()print 'Total dataset shape',digits.data.shape#------------- data prepare#75% training set,25% testing setX_train,X_test,y_train,y_test=train_test_split(digits.data,digits.target,test_size=0.25,random_state=33)print 'training data shape',y_train.shapeprint 'testing data shape',y_test.shape#------------- trainingss=StandardScaler()X_train=ss.fit_transform(X_train)X_test=ss.transform(X_test)#initialize LinearSVClsvc=LinearSVC()#training modellsvc.fit(X_train,y_train)#use trained model to predict testing dataset,and store the result on y_predicty_predict=lsvc.predict(X_test)#------------- performance measureprint 'The Accuracy is',lsvc.score(X_test,y_test)print classification_report(y_test,y_predict,target_names=digits.target_names.astype(str))Result:
Total dataset shape (1797, 64)
training data shape (1347,)
testing data shape (450,)
The Accuracy of Linear SVC is 0.953333333333
precision recall f1-score support
0 0.92 1.00 0.96 35
1 0.96 0.98 0.97 54
2 0.98 1.00 0.99 44
3 0.93 0.93 0.93 46
4 0.97 1.00 0.99 35
5 0.94 0.94 0.94 48
6 0.96 0.98 0.97 51
7 0.92 1.00 0.96 35
8 0.98 0.84 0.91 58
9 0.95 0.91 0.93 44
avg / total 0.95 0.95 0.95 450
- 支持向量机-手写数字识别
- 【Kaggle笔记】手写数字识别分类(线性支持向量机)
- 利用SVM(支持向量机)和MNIST库在OpenCV环境下实现手写数字0~9的识别
- 各种机器学习方法(线性回归、支持向量机、决策树、朴素贝叶斯、KNN算法、逻辑回归)实现手写数字识别并用准确率、召回率、F1进行评估
- 利用支持向量机(SVM)做手写数字识别
- [机器学习]支持向量机及其应用---手写识别系统(SMO算法)
- 手写数字识别实验
- 手写数字识别
- 识别手写数字
- CNN 手写数字识别
- SVM - 手写数字识别
- caffe识别手写数字
- KNN手写数字识别
- 手写数字识别实现
- SVM手写数字识别
- tensorflow识别手写数字
- 手写数字识别
- MNIST手写数字识别
- 计算字符串最后一个单词的长度,单词以空格隔开
- hive基本概念
- 使用java代码实现邮件的发送
- Java程序语言的命名规范
- 前端开发人员应考虑哪些SEO优化技巧
- 支持向量机-手写数字识别
- ListView 设置Item高度
- 使用JDBC进行数据库的事务操作(1)
- ubuntu 16.04 下安装最新版本wineQQ
- 预处理器
- jq中的克隆用法
- 从XCode里导出文档
- Android Binder机制介绍
- 工作常用正则规则验证代码,欢迎补充