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 language bindings for LIBSVM

License

BSD-3-Clause, MIT licenses found

Licenses found

BSD-3-Clause
LIBSVM-LICENSE
MIT
MIT-LICENSE
NotificationsYou must be signed in to change notification settings

febeling/rb-libsvm

Repository files navigation

Gem Version

rb-libsvm -- Ruby language bindings for LIBSVM

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

There is a JRuby implementation of this gem namedjrb-libsvm byAndreas Eger.

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

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

It is helpful to consult theREADME of the LIBSVM package forreference when configuring the training parameters.

Currently this package includes libsvm version 3.24.

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 defaultpackaging) you will need to have Xcode installed, and from within Xcodeyou need to install the command line tools. Those contain the compilerwhich 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.newparameter=Libsvm::SvmParameter.newparameter.cache_size=1# in megabytesparameter.eps=0.001parameter.c=10examples=[[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. useBundler.require or use an environment that relies on it,like Rails), then you will need to specify rb-libsvm in the Gemfilelike this:

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

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

Release

The process to make a release of the gem package to rubygems.org has anumber of steps.

  • manually change the version inlib/libsvm/version.rb
  • clean, build, and run tests successfully
  • update code and documentation
  • push
  • sign intohttps://rubygems.org/
  • save API token fromhttps://rubygems.org/profile/edit and store in.gem/credentials by runninggem signin
  • perform actual release:bundle exec rake release

Author

Written byC. 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 underthe license in the file LIBSVM-LICENSE.

Posts about using SVMs with Ruby

https://www.practicalai.io/implementing-classification-using-a-svm-in-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/

About

Ruby language bindings for LIBSVM

Topics

Resources

License

BSD-3-Clause, MIT licenses found

Licenses found

BSD-3-Clause
LIBSVM-LICENSE
MIT
MIT-LICENSE

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp