Class: Liblinear::FeatureNodeMatrix

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

Instance Method Summary collapse

Constructor Details

#initialize(examples, bias) ⇒ FeatureNodeMatrix

Returns a new instance of FeatureNodeMatrix.

Parameters:

  • examples (Array <Array <Float> or Hash>)
  • bias (Float)


5
6
7
8
9
10
11
12
# File 'lib/liblinear/feature_node_matrix.rb', line 5

def initialize(examples, bias)
  @feature_node_matrix = Liblinearswig.feature_node_matrix(examples.size)
  max_feature_id = Liblinear::Example.max_feature_id(examples)
  examples.size.times do |index|
    feature_node = Liblinear::FeatureNode.new(examples[index], max_feature_id, bias)
    Liblinearswig.feature_node_matrix_set(@feature_node_matrix, index, feature_node.swig)
  end
end

Instance Method Details

#deleteObject



19
20
21
# File 'lib/liblinear/feature_node_matrix.rb', line 19

def delete
  Liblinearswig.feature_node_matrix_destroy(@feature_node_matrix)
end

#swigSWIG::TYPE_p_p_feature_node

Returns:

  • (SWIG::TYPE_p_p_feature_node)


15
16
17
# File 'lib/liblinear/feature_node_matrix.rb', line 15

def swig
  @feature_node_matrix
end