Class: Mirlo::Sample
- Inherits:
-
Object
- Object
- Mirlo::Sample
- Defined in:
- lib/mirlo/sample.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #==(other_sample) ⇒ Object
- #[](index) ⇒ Object
- #biased? ⇒ Boolean
- #feature_size ⇒ Object
- #has_features?(some_features) ⇒ Boolean
-
#initialize(target: [], features: []) ⇒ Sample
constructor
A new instance of Sample.
- #target_size ⇒ Object
Constructor Details
#initialize(target: [], features: []) ⇒ Sample
Returns a new instance of Sample.
4 5 6 7 |
# File 'lib/mirlo/sample.rb', line 4 def initialize(target: [], features: []) @target = target.is_a?(Array) ? target : [target] @features = features end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
2 3 4 |
# File 'lib/mirlo/sample.rb', line 2 def features @features end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
2 3 4 |
# File 'lib/mirlo/sample.rb', line 2 def target @target end |
Instance Method Details
#==(other_sample) ⇒ Object
29 30 31 32 33 |
# File 'lib/mirlo/sample.rb', line 29 def ==(other_sample) target == other_sample.target && features == other_sample.features && biased? == other.biased? end |
#[](index) ⇒ Object
9 10 11 |
# File 'lib/mirlo/sample.rb', line 9 def [](index) @features[index] end |
#biased? ⇒ Boolean
25 26 27 |
# File 'lib/mirlo/sample.rb', line 25 def biased? false end |
#feature_size ⇒ Object
17 18 19 |
# File 'lib/mirlo/sample.rb', line 17 def feature_size features.size end |
#has_features?(some_features) ⇒ Boolean
13 14 15 |
# File 'lib/mirlo/sample.rb', line 13 def has_features?(some_features) features == some_features end |
#target_size ⇒ Object
21 22 23 |
# File 'lib/mirlo/sample.rb', line 21 def target_size target.size end |