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