zoukankan      html  css  js  c++  java
  • 数学之路(3)-机器学习(3)-机器学习算法-SVM[9]

    我们应用SVM的非线性分类功能对手写数字进行识别,我们在这应用poly做为非线性核

     

    svm = mlpy.LibSvm(svm_type='c_svc', kernel_type='poly',gamma=10)
    svm.learn(x, y)


    我们按像素分块读取数字特征后,形成训练样本,送入SVM训练

    本博客所有内容是原创,如果转载请注明来源

    http://blog.csdn.net/myhaspl/



    对样本本身测试

    print svm.pred(x)


    对供测试的未知样本进行测试


    测试代码如下:

    for iii in xrange (1,10):
        testfn= 'nums/test/'+str(iii)+'-test.png'
        testx=[]
        testx.append(getnumc(testfn))
        print svm.pred(testx)


    识别效果还可以,通过增加笔型差异较大的训练样本,效果将更好

    >>> runfile(r'I:ook_prog umsbsvm.py', wdir=r'I:ook_prog')

    http://blog.csdn.net/myhaspl
    myhaspl@qq.com


    loading  ...
    [ 1.  1.  1.  1.  2.  2.  2.  2.  3.  3.  3.  3.  4.  4.  4.  4.  5.  5.
      5.  5.  6.  6.  6.  6.  7.  7.  7.  7.  8.  8.  8.  8.  9.  9.  9.  9.]
    [ 1.]
    [ 2.]
    [ 3.]
    [ 4.]
    [ 5.]
    [ 6.]
    [ 7.]
    [ 8.]
    [ 9.]
    >>> 


  • 相关阅读:
    linux ss 命令
    linux netstat 命令
    linux firewalld 命令
    linux sshd 服务
    linux rysnc 命令(远程复制)
    linux scp 命令
    linux ifconfig
    linux /var/log 日志文件
    linux systemctrl 命令
    linux 创建新用户并设置管理员权限
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3323022.html
Copyright © 2011-2022 走看看