Class: Problem
- Inherits:
-
Object
- Object
- Problem
- Defined in:
- lib/svm.rb
Instance Attribute Summary collapse
-
#maxlen ⇒ Object
Returns the value of attribute maxlen.
-
#prob ⇒ Object
Returns the value of attribute prob.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(y, x) ⇒ Problem
constructor
A new instance of Problem.
- #inspect ⇒ Object
Constructor Details
#initialize(y, x) ⇒ Problem
Returns a new instance of Problem.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/svm.rb', line 138 def initialize(y,x) #assert y.size == x.size @prob = prob = Svm_problem.new @size = size = y.size @y_array = y_array = new_double(size) for i in (0..size-1) double_setitem(@y_array,i,y[i]) end @x_matrix = x_matrix = svm_node_matrix(size) @data = [] @maxlen = 0 for i in (0..size-1) data = _convert_to_svm_node_array(x[i]) @data << data svm_node_matrix_set(x_matrix,i,data) if x[i].class == Hash if x[i].size > 0 @maxlen = [@maxlen,x[i].keys.max].max end else @maxlen = [@maxlen,x[i].size].max end end prob.l = size prob.y = y_array prob.x = x_matrix end |
Instance Attribute Details
#maxlen ⇒ Object
Returns the value of attribute maxlen.
136 137 138 |
# File 'lib/svm.rb', line 136 def maxlen @maxlen end |
#prob ⇒ Object
Returns the value of attribute prob.
136 137 138 |
# File 'lib/svm.rb', line 136 def prob @prob end |
#size ⇒ Object
Returns the value of attribute size.
136 137 138 |
# File 'lib/svm.rb', line 136 def size @size end |
Instance Method Details
#destroy ⇒ Object
173 174 175 176 177 178 179 180 |
# File 'lib/svm.rb', line 173 def destroy delete_svm_problem(@prob) delete_double(@y_array) for i in (0..size-1) svm_node_array_destroy(@data[i]) end svm_node_matrix_destroy(@x_matrix) end |
#inspect ⇒ Object
169 170 171 |
# File 'lib/svm.rb', line 169 def inspect return "Problem: size = #{size}" end |