Code Monkey home page Code Monkey logo

trupysvmlight's Introduction

TruPySVMLight

Python re-implementation of Bill Cauchois's C-based pysvmlight Python-to-SVM interface (hosted on Bitbucket): https://bitbucket.org/wcauchois/pysvmlight/

A Python binding to the SVM-Light support vector machine library by Thorsten Joachims.

Translation to Python by Ceri Stagg and by David Campbell, Hacker School project, NYC, summer 2012. Original PySVMLight by Bill Cauchois.

Installation

PySVMLight uses distutils for setup. Installation is as simple as

$ chmod +x setup.py
$ ./setup.py --help
$ ./setup.py build

If you want to install SVMLight to your PYTHONPATH, type:

$ ./setup.py install

(You may need to execute this command as the superuser.) Otherwise, look in the build/ directory to find svmlight.so and copy that file to the directory of your project. You should now be able to import svmlight.

Getting Started

See examples/simple.py for example usage.

Reference

If you type help(svmlight), you will see that there are currently three functions.

learn(training_data, **options) -> model

Train a model based on a set of training data. The training data should be in the following format:

>> (<label>, [(<feature>, <value>), ...])

or

>> (<label>, [(<feature>, <value>), ...], <queryid>)

See examples/data.py for an example of some training data. Available options include (corresponding roughly to the command-line options for svmlight detailed on this page under the section titled "How to use"):

  • type: select between 'classification', 'regression', 'ranking' (preference ranking), and 'optimization'.
  • kernel: select between 'linear', 'polynomial', 'rbf', and 'sigmoid'.
  • verbosity: set the verbosity level (default 0).
  • C: trade-off between training error and margin.
  • poly_degree: parameter d in polynomial kernel.
  • rbf_gamma: parameter gamma in rbf kernel.
  • coef_lin
  • coef_const

The result of this call is a model that you can pass to classify().

classify(model, test_data, **options) -> predictions

Classify a set of test data using the provided model. The test data should be in the same format as training data (see above). The result will be a list of floats, corresponding to predicted labels for each of the test instances.

write_model(model, filename) -> None

Write the provided model to the specified file. The file format used is the same format as that used by the command-line svmlight program.

read_model(filename) -> model

Read a model that was saved using write_model().

trupysvmlight's People

Contributors

cpstagg avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

wanderlustzoe

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.