Coder Social home page Coder Social logo

libsvm-go's Introduction

libsvm-go: Support Vector Machine

This is a full port of LIBSVM in the Go programming language. LIBSVM is a suite of tools and an API library for support vector classification, regression, and distribution estimation. This port implements the libsvm library in the form of a Go package called libSvm. It also implements the svm-train and svm-predict command line tools.

This port has no external package dependencies, and uses only the native standard library.

Installation

go get github.com/ewalker544/libsvm-go
make

Compatibility Notes

I have tried to make the Go implementation of svm-train and svm-predict plug-in compatibile with the original LIBSVM 3.18 distribution. This is to allow you to use the other tools available in the original distribution, like easy.py and grid.py.

svm-predict should be 100% plug-in compatibile. However, svm-train is plug-in compatible with one exception. The exception is the parameter weight flag used in the command. In this implementation, the flag is

-w i,weight : set the parameter C of class i to weight*C, for C-SVC (default 1)

For full documentation of the svm-train and svm-predict commands, please refer to the original LIBSVM web site.

API Example

Training

import "github.com/ewalker544/libsvm-go"
    
param := libSvm.NewParameter()      // Create a parameter object with default values
param.KernelType = libSvm.POLY      // Use the polynomial kernel
    
model := libSvm.NewModel(param)     // Create a model object from the parameter attributes
    
// Create a problem specification from the training data and parameter attributes
problem, err := libSvm.NewProblem("a9a.train", param) 
    
model.Train(problem)                // Train the model from the problem specification
    
model.Dump("a9a.model")             // Dump the model into a user-specified file

Predicting

import "github.com/ewalker544/libsvm-go"
    
// Create a model object from the model file generated from training
model := libSvm.NewModelFromFile("a9a.model")  
    
x := make(map[int]float64)
// Populate x with the test vector
    
predictLabel := model.Predict(x)    // Predicts a float64 label given the test vector 

libsvm-go's People

Contributors

climber544 avatar ewalker544 avatar aaronjstewart avatar

Watchers

live2learn avatar

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.