Class: Liblinear::Parameter
- Inherits:
-
Object
- Object
- Liblinear::Parameter
- Includes:
- Liblinear, Liblinearswig
- Defined in:
- lib/liblinear/parameter.rb
Constant Summary
Constants included from Liblinear
L1R_L2LOSS_SVC, L1R_LR, L2R_L1LOSS_SVC_DUAL, L2R_L1LOSS_SVR_DUAL, L2R_L2LOSS_SVC, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVR, L2R_L2LOSS_SVR_DUAL, L2R_LR, L2R_LR_DUAL, MCSVM_CS, VERSION
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Parameter
constructor
A new instance of Parameter.
- #method_missing(m, *args) ⇒ Object
- #weight=(weight) ⇒ Object
- #weight_label=(weight_label) ⇒ Object
Methods included from Liblinear
#array_to_hash, #convert_to_feature_node_array, #double_array_c_to_ruby, #free_double_array, #free_int_array, #int_array_c_to_ruby, #max_index, #new_double_array, #new_int_array
Constructor Details
#initialize(params = {}) ⇒ Parameter
Returns a new instance of Parameter.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/liblinear/parameter.rb', line 8 def initialize(params = {}) @params = Liblinearswig::Parameter.new self.solver_type = 1 self.C = 1 self.eps = 0.1 self.p = 0.1 self.nr_weight = 0 self.weight_label = [] self.weight = [] params.each do |k, v| self.send("#{k}=", v) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/liblinear/parameter.rb', line 34 def method_missing(m, *args) if m.to_s.index('=') @params.send(m.to_sym, args.first) else @params.send(m.to_sym) end end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/liblinear/parameter.rb', line 5 def params @params end |
Instance Method Details
#weight=(weight) ⇒ Object
29 30 31 32 |
# File 'lib/liblinear/parameter.rb', line 29 def weight=(weight) free_double_array(@params.weight) @params.weight = new_double_array(weight) end |
#weight_label=(weight_label) ⇒ Object
23 24 25 26 |
# File 'lib/liblinear/parameter.rb', line 23 def weight_label=(weight_label) free_int_array(@params.weight_label) @params.weight_label = new_int_array(weight_label) end |