module Spark::Mllib::Vectors
Public Class Methods
dense(*args)
click to toggle source
# File lib/spark/mllib/vector.rb, line 5 def self.dense(*args) DenseVector.new(*args) end
parse(data)
click to toggle source
# File lib/spark/mllib/vector.rb, line 13 def self.parse(data) if data.start_with?('[') && data.end_with?(']') DenseVector.parse(data) elsif data.start_with?('(') && data.end_with?(')') SparseVector.parse(data) else raise ArgumentError, 'Unknow vector.' end end
sparse(*args)
click to toggle source
# File lib/spark/mllib/vector.rb, line 9 def self.sparse(*args) SparseVector.new(*args) end
to_vector(data)
click to toggle source
# File lib/spark/mllib/vector.rb, line 23 def self.to_vector(data) if data.is_a?(SparseVector) || data.is_a?(DenseVector) data elsif data.is_a?(Array) DenseVector.new(data) end end