Class: LParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/linear.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ LParameter

Returns a new instance of LParameter.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/linear.rb', line 53

def initialize(*args)
  @param = Parameter.new
  @param.solver_type = L2R_LR
  @param.C = 1
  @param.eps = 0.01
  @param.nr_weight = 0
  @param.weight_label = _int_array([])
  @param.weight = _double_array([])
  
  args[0].each {|k,v| 
    self.send("#{k}=",v)
  } if !args[0].nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/linear.rb', line 67

def method_missing(m, *args)
  #print m.to_s
  #puts args.inspect
  if m.to_s == 'weight_label='
    @weight_label_len = args[0].size
    pargs = _int_array(args[0])
    _free_int_array(@param.weight_label)
  elsif m.to_s == 'weight='
    @weight_len = args[0].size
    pargs = _double_array(args[0])
    _free_double_array(@param.weight)
  else
    pargs = args[0]
  end
  
  if m.to_s.index('=')
    @param.send("#{m}",pargs)
  else
    @param.send("#{m}")
  end
  
end

Instance Attribute Details

#paramObject

Returns the value of attribute param.



51
52
53
# File 'lib/linear.rb', line 51

def param
  @param
end

Instance Method Details

#destroyObject



94
95
96
97
98
99
# File 'lib/linear.rb', line 94

def destroy
  _free_int_array(@param.weight_label)
  _free_double_array(@param.weight)
  delete_parameter(@param)
  @param = nil
end

#inspectObject



90
91
92
# File 'lib/linear.rb', line 90

def inspect
  "LParameter: solver_type=#{@param.solver_type} C=#{@param.C} eps=#{@param.eps}"
end