Sha256: c9b6f03ac3b73c8aef0fc8e0d2dda850829bb52dca462d88f18ad1d6be1f8750

Contents?: true

Size: 477 Bytes

Versions: 21

Compression:

Stored size: 477 Bytes

Contents

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}"

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rb-libsvm-1.4.4 examples/toy.rb
rb-libsvm-1.4.3 examples/toy.rb
rb-libsvm-1.4.2 examples/toy.rb
rb-libsvm-1.4.1 examples/toy.rb
rb-libsvm-1.4.0 examples/toy.rb
rb-libsvm-1.3.1 examples/toy.rb
rb-libsvm-1.3.0 examples/toy.rb
rb-libsvm-1.2.0 examples/toy.rb
rb-libsvm-1.1.5 examples/toy.rb
rb-libsvm-1.1.4 examples/toy.rb
rb-libsvm-1.1.3 examples/toy.rb
rb-libsvm-1.1.2 examples/toy.rb
rb-libsvm-1.1.1 examples/toy.rb
rb-libsvm-1.1.0 examples/toy.rb
rb-libsvm-1.0.11 examples/toy.rb
rb-libsvm-1.0.10 examples/toy.rb
rb-libsvm-1.0.9 examples/toy.rb
rb-libsvm-1.0.8 examples/toy.rb
rb-libsvm-1.0.7 examples/toy.rb
rb-libsvm-1.0.6 examples/toy.rb