国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

武漢漢口做網(wǎng)站公司訊展網(wǎng)站優(yōu)化推廣

武漢漢口做網(wǎng)站公司,訊展網(wǎng)站優(yōu)化推廣,買了個(gè)服務(wù)器 怎么做網(wǎng)站,我的世界服務(wù)器如何做充錢網(wǎng)站HOGSVM數(shù)字識(shí)別 1 . 步驟2 . 代碼 1 . 步驟 讀入數(shù)據(jù),把數(shù)據(jù)劃分為訓(xùn)練集和測(cè)試集用hog提取特征用SVM訓(xùn)練數(shù)據(jù)測(cè)試、評(píng)價(jià)模型保存模型加載模型,應(yīng)用模型 2 . 代碼 import os import cv2 import sklearn import numpy as np from skimage.feature impo…

HOG+SVM數(shù)字識(shí)別

  • 1 . 步驟
  • 2 . 代碼

1 . 步驟

  1. 讀入數(shù)據(jù),把數(shù)據(jù)劃分為訓(xùn)練集和測(cè)試集
  2. 用hog提取特征
  3. 用SVM訓(xùn)練數(shù)據(jù)
  4. 測(cè)試、評(píng)價(jià)模型
  5. 保存模型
  6. 加載模型,應(yīng)用模型

2 . 代碼

import os
import cv2
import sklearn
import numpy as np
from skimage.feature import hog
from skimage import data,exposure
from sklearn import svm
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
import seaborn as sn
import pandas  as pd
from joblib import dump,load
from sklearn.metrics import confusion_matrix# 1. 讀入數(shù)據(jù)
# 1.1 處理數(shù)據(jù),獲取圖像的地址和標(biāo)簽,劃分訓(xùn)練集、測(cè)試集,對(duì)數(shù)據(jù)集打亂順序
data_path = r'./hand_nums'
tmp_train = os.listdir(data_path+'/train')
tmp_test = os.listdir(data_path+'/test')
train_x ,test_x = [],[]
## 1.2 獲取圖像的地址,把訓(xùn)練集和測(cè)試集的特征和標(biāo)簽
test_y ,test_y = [],[]
for i in tmp_train:if i.endswith('.bmp'):train_x.append(data_path+'/train/'+i)train_y.append(int(i.split('-')[0]))
for i in tmp_test:if i.endswith('.bmp'):test_x.append(data_path+'/test/'+i)test_y.append(int(i.split('.')[0]))
## 1.3 打亂數(shù)據(jù)的順序
## 訓(xùn)練集、測(cè)試集的下標(biāo)
train_idx = np.arange(len(train_x))
test_idx = np.arange(len(test_x))
## 打亂順序
np.random.shuffle(train_idx)
np.random.shuffle(test_idx)
## 訓(xùn)練集、測(cè)試集打亂順序
train_x = list(np.array(train_x)[train_idx])
test_x = list(np.array(test_x)[test_idx])
train_y = list(np.array(train_y)[train_idx])
test_y = list(np.array(test_y)[test_idx])# 2. 用hog提取特征
## 2.1 hog實(shí)例化
train_feature,test_feature = [],[]
## 獲取訓(xùn)練集特征
for i in train_x:img_gray = cv2.imread(i,0)fd , img_hog = hog(img_gray,orientations=9,pixels_per_cell=(8,8),cells_per_block=(2,2),visualize=True)train_feature.append(img_hog.flatten())
## 獲取測(cè)試集特征
for i in test_x:img_gray = cv2.imread(i,0)fd,img_hog = hog(img_gray,orientations=9,pixels_per_cell=(8,8),cells_per_block=(2,2),visualize=True)test_feature.append(img_hog.flatten())# 3 SVM訓(xùn)練
clf = svm.SVC(decision_function_shape='ovo')
clf.fit(train_feature ,train_y)
# 4. 測(cè)試、評(píng)價(jià)模型
dec = clf.decision_function(test_feature)
pred_y = clf.predict(test_feature)
accuracy_score(pred_y,test_y)
# 5. 保存模型
from joblib import dump,load
## 保存模型
dump(clf,'./hand_nums/models/poly.joblib')
## 加載模型
new_cls = load('./hand_nums/models/poly.joblib')
pred_y = new_cls.predict(test_feature)
accuracy_score(pred_y,test_y)# 6. 加載模型,應(yīng)用模型
clf_poly = svm.SVC(decision_function_shape='ovo',kernel='poly')
clf_poly.fit(train_feature ,train_y)
dec = clf_poly.decision_function(test_feature)
pred_y = clf_poly.predict(test_feature)
accuracy_score(pred_y,test_y)clf_linear = svm.SVC(decision_function_shape='ovo',kernel='linear')
clf_linear.fit(train_feature ,train_y)
dec = clf_linear.decision_function(test_feature)
pred_y = clf_linear.predict(test_feature)
accuracy_score(pred_y,test_y)
cm = confusion_matrix(test_y,pred_y)df_cm = pd.Dataframe(cm,index=[i for i in ['0','1','2','3','4','5','6','7','8','9']],columns = [i for i in ['0','1','2','3','4','5','6','7','8','9']])
plt.figure(figsize=(10,7))
sn.heatmap(df_cm,annot=True,cmap='Green',fmt='d')

準(zhǔn)確率 1.0
嘻嘻😁
數(shù)據(jù)集:鏈接:https://pan.baidu.com/s/1yFCJvcswdSgGcAN6n9u-nA 密碼:ryqo

http://m.aloenet.com.cn/news/42394.html

相關(guān)文章:

  • 湖北省建設(shè)質(zhì)量安全協(xié)會(huì)網(wǎng)站seo網(wǎng)站推廣專員招聘
  • 網(wǎng)站在阿里云備案免費(fèi)數(shù)據(jù)統(tǒng)計(jì)網(wǎng)站
  • 禮品公司網(wǎng)站建設(shè)好的競(jìng)價(jià)托管公司
  • 天津建設(shè)工程信息網(wǎng)專家sem 優(yōu)化價(jià)格
  • 網(wǎng)站上添加子欄目濰坊百度網(wǎng)站排名
  • 深圳網(wǎng)站建設(shè)公司是選擇寧波seo優(yōu)化公司
  • 備案上個(gè)人網(wǎng)站和企業(yè)網(wǎng)站的區(qū)別百度sem是什么意思
  • wordpress開啟多站點(diǎn)功網(wǎng)絡(luò)營銷有哪些特點(diǎn)
  • 網(wǎng)站優(yōu)化 代碼優(yōu)化互聯(lián)網(wǎng)優(yōu)化
  • 如何為網(wǎng)站開發(fā)app中公教育培訓(xùn)機(jī)構(gòu)官網(wǎng)
  • 便宜網(wǎng)站建設(shè)公司如何建立自己的網(wǎng)站平臺(tái)
  • 微信怎么做捐錢的網(wǎng)站網(wǎng)站推廣費(fèi)用
  • 一站式裝修平臺(tái)杭州seo論壇
  • 網(wǎng)頁設(shè)計(jì)網(wǎng)站建設(shè)過程報(bào)告免費(fèi)網(wǎng)站入口在哪
  • 石碣仿做網(wǎng)站seo技術(shù)分享博客
  • 知名跟單網(wǎng)站做信號(hào)提供方女教師網(wǎng)課入06654侵錄屏
  • 安徽做網(wǎng)站免費(fèi)seo排名軟件
  • 石家莊便宜網(wǎng)站制作html底部友情鏈接代碼
  • 做動(dòng)態(tài)網(wǎng)站的軟件有哪些最近軍事新聞熱點(diǎn)大事件
  • 為什么做民宿網(wǎng)站百度競(jìng)價(jià)排名公式
  • 網(wǎng)站開發(fā)設(shè)計(jì)定制百度谷歌seo優(yōu)化
  • 開發(fā)一個(gè)網(wǎng)站測(cè)試要怎么做的seo平臺(tái)優(yōu)化服務(wù)
  • 上海網(wǎng)站建設(shè)品ui培訓(xùn)
  • 網(wǎng)站集約化建設(shè)情況匯報(bào)網(wǎng)絡(luò)營銷咨詢服務(wù)
  • 做網(wǎng)站域名 空間廣州競(jìng)價(jià)托管
  • 學(xué)校網(wǎng)站群建設(shè)方案找個(gè)網(wǎng)站
  • 淘客請(qǐng)人做網(wǎng)站網(wǎng)站策劃書
  • 做網(wǎng)站大概要多外鏈怎么打開
  • 如何建設(shè)網(wǎng)站的管理平臺(tái)免費(fèi)網(wǎng)站seo
  • 婁底網(wǎng)站建設(shè)工作室谷歌收錄查詢