Class: Liblinear::Model
- Inherits:
-
Object
- Object
- Liblinear::Model
- Defined in:
- lib/liblinear/model.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bias ⇒ Float
- #class_size ⇒ Integer
- #feature_size ⇒ Integer
- #feature_weights ⇒ Array <Float>
- #labels ⇒ Array <Integer>
- #load(file_name) ⇒ Object
- #probability_model? ⇒ Boolean
- #regression_model? ⇒ Boolean
- #save(filename) ⇒ Object
- #swig ⇒ Liblinear::Model
- #train(problem, parameter) ⇒ Object
Class Method Details
.load(file_name) ⇒ Liblinear::Model
15 16 17 18 19 |
# File 'lib/liblinear/model.rb', line 15 def load(file_name) model = self.new model.load(file_name) model end |
.train(problem, parameter) ⇒ Liblinear::Model
7 8 9 10 11 |
# File 'lib/liblinear/model.rb', line 7 def train(problem, parameter) model = self.new model.train(problem, parameter) model end |
Instance Method Details
#bias ⇒ Float
59 60 61 |
# File 'lib/liblinear/model.rb', line 59 def bias @model.bias end |
#class_size ⇒ Integer
44 45 46 |
# File 'lib/liblinear/model.rb', line 44 def class_size @model.nr_class end |
#feature_size ⇒ Integer
49 50 51 |
# File 'lib/liblinear/model.rb', line 49 def feature_size @model.nr_feature end |
#feature_weights ⇒ Array <Float>
54 55 56 |
# File 'lib/liblinear/model.rb', line 54 def feature_weights Liblinear::Array::Double.decode(@model.w, feature_size) end |
#labels ⇒ Array <Integer>
64 65 66 |
# File 'lib/liblinear/model.rb', line 64 def labels Liblinear::Array::Integer.decode(@model.label, class_size) end |
#load(file_name) ⇒ Object
29 30 31 |
# File 'lib/liblinear/model.rb', line 29 def load(file_name) @model = Liblinearswig.load_model(file_name) end |
#probability_model? ⇒ Boolean
69 70 71 |
# File 'lib/liblinear/model.rb', line 69 def probability_model? Liblinearswig.check_probability_model(@model) == 1 ? true : false end |
#regression_model? ⇒ Boolean
74 75 76 |
# File 'lib/liblinear/model.rb', line 74 def regression_model? Liblinearswig.check_regression_model(@model) == 1 ? true : false end |
#save(filename) ⇒ Object
39 40 41 |
# File 'lib/liblinear/model.rb', line 39 def save(filename) Liblinearswig.save_model(filename, @model) end |
#train(problem, parameter) ⇒ Object
24 25 26 |
# File 'lib/liblinear/model.rb', line 24 def train(problem, parameter) @model = Liblinearswig.train(problem.swig, parameter.swig) end |