Module: Spark::Mllib::Vectors
- Defined in:
- lib/spark/mllib/vector.rb
Class Method Summary collapse
Class Method Details
.dense(*args) ⇒ Object
5 6 7 |
# File 'lib/spark/mllib/vector.rb', line 5 def self.dense(*args) DenseVector.new(*args) end |
.parse(data) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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) ⇒ Object
9 10 11 |
# File 'lib/spark/mllib/vector.rb', line 9 def self.sparse(*args) SparseVector.new(*args) end |
.to_vector(data) ⇒ Object
23 24 25 26 27 28 29 |
# 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 |