Giter Club home page Giter Club logo

svmfdh's Introduction

svm

  • svm.py
    该文件中实现了一个简单的SVM,使用SMO进行优化,在选择优化的变量时采用随机选择的方式。
  • plattSMO.py
    该文件也是采用SMO进行优化,在选择优化变量时,选择误差步长最大的两个变量进行优化,可以大幅提高优化速度。 该文件中还加入了核函数(线性核函数,RBF核函数),具体实现参见 kernelTrans(self,x,z)
  • libSVM.py
    该文件实现了一个SVM多分类器,其实现原理是:对于样本中的每两个类别之间都训练一个SVM二分类器。对于k个类别, 共可训练出k(k-1)/2个SVM二分类器。在预测时,将测试样例分别输入到k(k-1)/2分类器中。
    假设(i,j)表示划分类别i和类别j的SVM分类器
    对于每个分类器(i,j):
    若分类结果为+1,则count[i] +=1
    若分类结果为-1,则count[j] +=1
    最后分类结果取相应类别计数最大的那个类别作为最终分类结果
    本文件还实现了将训练的模型保存成文件,方便预测时直接从文件读取,省去了再次训练的时间。
    ** 例子
def main():
    '''
    data,label = loadImage('trainingDigits')
    svm = LibSVM(data, label, 200, 0.0001, 10000, name='rbf', theta=20)
    svm.train()
    svm.save("svm.txt")
    '''
    svm = LibSVM.load("svm.txt")
    test,testlabel = loadImage('testDigits')
    svm.predict(test,testlabel)

svmfdh's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.