Class: Datasets::LIBSVM::Record
- Inherits:
-
Object
- Object
- Datasets::LIBSVM::Record
- Defined in:
- lib/datasets/libsvm.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(label, features) ⇒ Record
constructor
A new instance of Record.
- #to_h ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(label, features) ⇒ Record
Returns a new instance of Record.
10 11 12 13 |
# File 'lib/datasets/libsvm.rb', line 10 def initialize(label, features) @label = label @features = features end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
9 10 11 |
# File 'lib/datasets/libsvm.rb', line 9 def features @features end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/datasets/libsvm.rb', line 8 def label @label end |
Instance Method Details
#[](index) ⇒ Object
15 16 17 |
# File 'lib/datasets/libsvm.rb', line 15 def [](index) @features[index] end |
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/datasets/libsvm.rb', line 19 def to_h hash = { label: @label, } @features.each_with_index do |feature, i| hash[i] = feature end hash end |
#values ⇒ Object
29 30 31 |
# File 'lib/datasets/libsvm.rb', line 29 def values [@label] + @features end |