资源简介
svm手写数字识别

代码片段和文件信息
from numpy import *
def loadDataSet(fileName):
dataMat = []
labelMat = []
fr = open(fileName)
for line in fr.readlines():
lineArr = line.strip().split(‘\t‘)
dataMat.append([float(lineArr[0]) float(lineArr[1])])
labelMat.append(float(lineArr[2]))
return dataMat labelMat
def selectJrand(i m):
j = i
while (j == i):
j = int(random.uniform(0 m))
return j
# 调整alpha值
def clipAlpha(aj H L):
if aj > H:
aj = H
if L > aj:
aj = L
return aj
def smoSimple(dataMatIn classLabels C toler maxIter):
dataMatrix = mat(dataMatIn)
labelMat = mat(classLabels).transpose()
b = 0
m n = shape(dataMatrix)
alphas = mat(zeros((m 1)))
iter = 0
while (iter < maxIter):
alphaPairsChanged = 0
for i in range(m):
fXi = float(multiply(alphas labelMat).T * (dataMatrix * dataMatrix[i :].T)) + b
Ei = fXi - float(labelMat[i])
if ((labelMat[i] * Ei < -toler) and (alphas[i] < C)) or ((labelMat[i] * Ei > toler) and (alphas[i] > 0)):
j = selectJrand(i m) # 从0到m选出不等于i的随机数
fXj = float(multiply(alphas labelMat).T * (dataMatrix * dataMatrix[j :].T)) + b
Ej = fXj - float(labelMat[j])
alphaIold = alphas[i].copy()
alphaJold = alphas[j].copy()
if (labelMat[i] != labelMat[j]):
L = max(0 alphas[j] - alphas[i])
H = min(C C + alphas[j] - alphas[i])
else:
L = max(0 alphas[j] + alphas[i] - C)
H = min(C alphas[j] + alphas[i])
if L == H:
print(“L==H“)
continue
eta = 2.0 * dataMatrix[i :] * dataMatrix[j :].T \
- dataMatrix[i :] * dataMatrix[i :].T \
- dataMatrix[j :] * dataMatrix[j :].T
if eta >= 0:
print(“eta>=0“)
continue
alphas[j] -= labelMat[j] * (Ei - Ej) / eta
alphas[j] = clipAlpha(alphas[j] H L)
if (abs(alphas[j] - alphaJold) < 0.00001):
print(“j not moving enough“)
continue
alphas[i] += labelMat[j] * labelMat[i] * (alphaJold - alphas[j])
b1 = b - Ei - labelMat[i] * (alphas[i] - alphaIold) * dataMatrix[i :] * dataMatrix[i :].T - labelMat[
j] * (
alphas[
j] - alphaJold) * dataMatrix[
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-10 16:05 test5\
目录 0 2017-02-10 23:25 test5\.idea\
目录 0 2017-02-07 15:03 test5\.idea\inspectionProfiles\
文件 228 2017-02-07 15:03 test5\.idea\inspectionProfiles\profiles_settings.xm
文件 226 2017-02-07 15:06 test5\.idea\misc.xm
文件 262 2017-02-07 15:03 test5\.idea\modules.xm
文件 398 2017-02-07 15:06 test5\.idea\test5.iml
文件 25948 2017-02-10 23:25 test5\.idea\workspace.xm
文件 14260 2017-02-10 16:05 test5\svmMLiA.py
目录 0 2017-02-10 16:04 test5\testDigits\
文件 1088 2010-10-07 05:35 test5\testDigits\1_0.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_1.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_10.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_11.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_12.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_13.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_14.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_15.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_16.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_17.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_18.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_19.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_2.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_20.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_21.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_22.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_23.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_24.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_25.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_26.txt
文件 1088 2010-10-07 05:35 test5\testDigits\1_27.txt
............此处省略573个文件信息
- 上一篇:SVM教程PPT
- 下一篇:基于SystemView的2ask相干调制与解调
相关资源
- 基于OpenCV的数字识别468815
- 手写数字识别-模板匹配法
- GUI数字识别系统代码
- 基于Tensorflow多层神经网络的MNIST手写
- HOG+SVM实现数字识别
- stm32+ov7670数字识别
- 卷积神经网络实现手写数字识别
- MNIST数据集 txt版
- 3种模板匹配法实现的手写数字识别
- 基于CNN的手写数字识别
- 基于FPGA的印刷体数字识别系统设计
- mnist_10k_sprite.png图片
- tesseract-ocr- 的字母数字识别
- BP数字识别代码——了解和测试BP神经
- 基于SVM的手写数字识别Opencv+图像集
- opencv 数字识别
- 用BP神经网络实现minist手写数字识别
- 基于STM32的数字字符识别.zip
- 精心整理的手写数字识别论文11篇
- 0-9数字识别样本
- 数字和英文字母识别
- BP神经网络实现手写体数字识别
- 并行化实现基于BP神经网络的手写体数
- 手写数字识别10000次cnn结果 (.caffem
- stm32单片机knn算法手写数字识别
- 3D MNIST-3D数字识别数据
- Tesseract 4.0 for VS2015及OpenCV数字识别程
- 使用OpenCV 手势识别
- USPS手写体数字识别图片库
- 手写数字9000张图片.rar
评论
共有 条评论