Liblinear-Ruby
Liblinear-Ruby is Ruby interface to LIBLINEAR(1.9.3) using SWIG.
Installation
Add this line to your application's Gemfile:
gem 'liblinear-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install liblinear-ruby
Usage
require 'liblinear'
pa = Liblinear::Parameter.new({solver_type: 0})
bias = 0.5
labels = [1, 2]
# examples must be Array of Hash or Array
examples = [
{1=>0, 2=>0, 3=>0, 4=>0, 5=>0},
{1=>1, 2=>1, 3=>1, 4=>1, 5=>1}
]
pr = Liblinear::Problem.new(labels, examples, bias)
m = Liblinear::Model.new(pr, pa)
puts m.predict({1=>1, 2=>1, 3=>1, 4=>1, 5=>1}) # => 2.0
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request