Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ruby interface to LIBSVM (using SWIG)

License

NotificationsYou must be signed in to change notification settings

tomz/libsvm-ruby-swig

Repository files navigation

This is the Ruby port of the LIBSVM Python SWIG (Simplified Wrapper and Interface Generator) interface.

A slightly modified version of LIBSVM 2.9 is included, it allows turrning on/off the debug log. You don’t need your own copy of SWIG to use this library - all needed files are generated using SWIG already.

Look for the README file in the ruby subdirectory for instructions. The binaries included were built under Ubuntu Linux 2.6.28-18-generic x86_64, you should run make under the libsvm-2.9 and libsvm-2.9/ruby directories to regenerate the executables for your environment.

LIBSVM is in use attweetsentiments.com - A Twitter / Tweet sentiment analysis application

Currently the gem is available on linux only(tested on Ubuntu 8-9 and Fedora 9-12, and on OS X by danielsdeleo), and you will need g++ installed to compile the native code.

sudo gem sources -a http://gems.github.com   (you only have to do this once)sudo gem install tomz-libsvm-ruby-swig

Quick Interactive Tutorial using irb (adopted from the python code from Toby Segaran’s “Programming Collective Intelligence” book):

irb(main):001:0> require 'svm'=> trueirb(main):002:0> prob = Problem.new([1,-1],[[1,0,1],[-1,0,-1]])irb(main):003:0> param = Parameter.new(:kernel_type => LINEAR, :C => 10)irb(main):004:0> m = Model.new(prob,param)irb(main):005:0> m.predict([1,1,1])=> 1.0irb(main):006:0> m.predict([0,0,1])=> 1.0irb(main):007:0> m.predict([0,0,-1])=> -1.0irb(main):008:0> m.save("test.model")irb(main):009:0> m2 = Model.new("test.model")irb(main):010:0> m2.predict([0,0,-1])=> -1.0

Tom Zeng

About

Ruby interface to LIBSVM (using SWIG)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp