Module: SVM

Extended by:
SVM
Included in:
SVM
Defined in:
lib/hex-svm.rb,
lib/libsvm/model.rb,
lib/libsvm/problem.rb,
lib/libsvm/parameter.rb

Defined Under Namespace

Classes: Model, Parameter, Problem

Instance Method Summary collapse

Instance Method Details

#convert_to_svm_node_array(indicies, max) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/hex-svm.rb', line 74

def convert_to_svm_node_array(indicies, max) 
  # Make index array
  # x = indexes_to_array(indicies, max)
  # iter_range = x.each_index.to_a
  
  data = svm_node_array(indicies.length + 1)
  svm_node_array_set(data, indicies.length, -1, 0)
  
  # max.times do |i|
  #   # Set to zero if not in indicies
  #   if indicies.include?(i)
  #     svm_node_array_set(data, i, i, 1)
  #   else
  #     svm_node_array_set(data, i, i, 0)
  #   end
  # end
  
  indicies.sort.each_with_index do |idx, i|
    svm_node_array_set(data, i, idx, 1)
  end

  data
end