Project

rumale-svm

0.0
A long-lived project that still receives updates
Rumale::SVM provides support vector machine algorithms using LIBSVM and LIBLINEAR with Rumale interface.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Rumale::SVM

Build Status Gem Version BSD 3-Clause License Documentation

Rumale::SVM provides support vector machine algorithms using LIBSVM and LIBLINEAR with Rumale interface.

Installation

Add this line to your application's Gemfile:

gem 'rumale-svm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rumale-svm

Documentation

Usage

Download pendigits dataset from LIBSVM DATA web page.

$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/pendigits
$ wget https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/pendigits.t

Training linear support vector classifier.

require 'rumale/svm'
require 'rumale/dataset'

samples, labels = Rumale::Dataset.load_libsvm_file('pendigits')
svc = Rumale::SVM::LinearSVC.new(random_seed: 1)
svc.fit(samples, labels)

File.open('svc.dat', 'wb') { |f| f.write(Marshal.dump(svc)) }

Evaluate classifiction accuracy on testing datase.

require 'rumale/svm'
require 'rumale/dataset'

samples, labels = Rumale::Dataset.load_libsvm_file('pendigits.t')
svc = Marshal.load(File.binread('svc.dat'))

puts "Accuracy: #{svc.score(samples, labels).round(3)}"

Execution result.

$ ruby rumale_svm_train.rb
$ ls svc.dat
svc.dat
$ ruby rumale_svm_test.rb
Accuracy: 0.835

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/rumale-svm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the BSD-3-Clause License.