Class: Mirlo::Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/mirlo/sample.rb

Direct Known Subclasses

SampleWithBias

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#featuresObject (readonly)

Returns the value of attribute features.



2
3
4
# File 'lib/mirlo/sample.rb', line 2

def features
  @features
end

#targetObject (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

Returns:

  • (Boolean)


25
26
27
# File 'lib/mirlo/sample.rb', line 25

def biased?
  false
end

#feature_sizeObject



17
18
19
# File 'lib/mirlo/sample.rb', line 17

def feature_size
  features.size
end

#has_features?(some_features) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/mirlo/sample.rb', line 13

def has_features?(some_features)
  features == some_features
end

#target_sizeObject



21
22
23
# File 'lib/mirlo/sample.rb', line 21

def target_size
  target.size
end