Class: Weka::Core::DenseInstance
- Inherits:
-
Object
- Object
- Weka::Core::DenseInstance
- Defined in:
- lib/weka/core/dense_instance.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #each_attribute ⇒ Object
- #each_attribute_with_index ⇒ Object
-
#initialize(data, weight: 1.0) ⇒ DenseInstance
constructor
A new instance of DenseInstance.
- #to_a ⇒ Object (also: #values)
Constructor Details
#initialize(data, weight: 1.0) ⇒ DenseInstance
Returns a new instance of DenseInstance.
9 10 11 12 13 14 15 |
# File 'lib/weka/core/dense_instance.rb', line 9 def initialize(data, weight: 1.0) if data.is_a?(Integer) super(data) else super(weight, to_java_double(data)) end end |
Instance Method Details
#attributes ⇒ Object
17 18 19 |
# File 'lib/weka/core/dense_instance.rb', line 17 def attributes enumerate_attributes.to_a end |
#each_attribute ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/weka/core/dense_instance.rb', line 21 def each_attribute if block_given? enumerate_attributes.each { |attribute| yield(attribute) } else enumerate_attributes end end |
#each_attribute_with_index ⇒ Object
29 30 31 32 33 |
# File 'lib/weka/core/dense_instance.rb', line 29 def each_attribute_with_index enumerate_attributes.each_with_index do |attribute, index| yield(attribute, index) if block_given? end end |
#to_a ⇒ Object Also known as: values
35 36 37 38 39 |
# File 'lib/weka/core/dense_instance.rb', line 35 def to_a to_double_array.each_with_index.map do |value, index| value_from(value, index) end end |