Class: Spark::Mllib::LabeledPoint
- Inherits:
-
Object
- Object
- Spark::Mllib::LabeledPoint
- Defined in:
- lib/spark/mllib/regression/labeled_point.rb
Overview
LabeledPoint
The features and labels of a data point.
Parameters:
- label
-
Label for this data point.
- features
-
Vector of features for this point
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(label, features) ⇒ LabeledPoint
constructor
A new instance of LabeledPoint.
- #marshal_dump ⇒ Object
- #marshal_load(array) ⇒ Object
Constructor Details
#initialize(label, features) ⇒ LabeledPoint
Returns a new instance of LabeledPoint.
19 20 21 22 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 19 def initialize(label, features) @label = label.to_f @features = Spark::Mllib::Vectors.to_vector(features) end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
17 18 19 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 17 def features @features end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
17 18 19 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 17 def label @label end |
Class Method Details
.from_java(object) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 24 def self.from_java(object) LabeledPoint.new( object.label, Spark.jb.java_to_ruby(object.features) ) end |
Instance Method Details
#marshal_dump ⇒ Object
31 32 33 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 31 def marshal_dump [@label, @features] end |
#marshal_load(array) ⇒ Object
35 36 37 |
# File 'lib/spark/mllib/regression/labeled_point.rb', line 35 def marshal_load(array) initialize(array[0], array[1]) end |