Git Product home page Git Product logo

rb-libsvm's Introduction

rb-libsvm -- Ruby language bindings for LIBSVM

Gem Version Build Status

This package provides a Ruby bindings to the LIBSVM library. SVM is a machine learning and classification algorithm, and LIBSVM is a popular free implementation of it, written by Chih-Chung Chang and Chih-Jen Lin, of National Taiwan University, Taipei. See the book "Programming Collective Intelligence," among others, for a usage example.

There is a JRuby implementation of this gem named jrb-libsvm by Andreas Eger.

Note: There exist some other Ruby bindings for LIBSVM. One is named Ruby SVM, written by Rudi Cilibrasi. The other, more actively developed one is libsvm-ruby-swig by Tom Zeng, which is built using SWIG.

LIBSVM includes a number of command line tools for preprocessing training data and finding parameters. These tools are not included in this gem. You should install the original package if you need them.

It is helpful to consult the README of the LIBSVM package for reference when configuring the training parameters.

Currently this package includes libsvm version 3.20.

Dependencies

None. LIBSVM is bundled with the project. Just install and go!

Installation

For building this gem from source on OS X (which is the default packaging) you will need to have Xcode installed, and from within Xcode you need to install the command line tools. Those contain the compiler which is necessary for the native code, and similar tools.

To install the gem run this command

gem install rb-libsvm

Usage

This is a short example of how to use the gem.

require 'libsvm'

# This library is namespaced.
problem = Libsvm::Problem.new
parameter = Libsvm::SvmParameter.new

parameter.cache_size = 1 # in megabytes

parameter.eps = 0.001
parameter.c = 10

examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
labels = [1, -1]

problem.set_examples(labels, examples)

model = Libsvm::Model.train(problem, parameter)

pred = model.predict(Libsvm::Node.features(1, 1, 1))
puts "Example [1, 1, 1] - Predicted #{pred}"

If you want to rely on Bundler for loading dependencies in a project, (i.e. use Bundler.require or use an environment that relies on it, like Rails), then you will need to specify rb-libsvm in the Gemfile like this:

gem 'rb-libsvm', require: 'libsvm'

This is because the loadable name (libsvm) is different from the gem's name (rb-libsvm).

Author

Written by C. Florian Ebeling.

Contributors

License

This software can be freely used under the terms of the MIT license, see file MIT-LICENSE.

This package includes the source of LIBSVM, which is free to use under the license in the file LIBSVM-LICENSE.

Posts about using SVMs with Ruby

http://neovintage.blogspot.com/2011/11/text-classification-using-support.html

http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/

rb-libsvm's People

Contributors

febeling avatar andreaseger avatar apohllo avatar neovintage avatar

Watchers

James Cloos avatar UM404 avatar  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.