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(&block) ⇒ Object
- #each_attribute_with_index(&block) ⇒ 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(&block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/weka/core/dense_instance.rb', line 21 def each_attribute(&block) if block_given? enumerate_attributes.each(&block) else enumerate_attributes end end |
#each_attribute_with_index(&block) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/weka/core/dense_instance.rb', line 29 def each_attribute_with_index(&block) if block_given? enumerate_attributes.each_with_index(&block) else enumerate_attributes end end |
#to_a ⇒ Object Also known as: values
37 38 39 40 41 |
# File 'lib/weka/core/dense_instance.rb', line 37 def to_a to_double_array.each_with_index.map do |value, index| value_from(value, index) end end |