Method: Weka::Core::Instances#add_instance

Defined in:
lib/weka/core/instances.rb

#add_instance(instance_or_values, weight: 1.0) ⇒ Object

Add new instance

Examples:

Passing Instance

instances.add_instance(instance)

Passing an array of attribute values

attr_values = [attr1_value, attr2_value, attr3_value]
instances.add_instance(attr_values)

Passing a hash of attribute values.

attr_values = { attr1_name: attr1_value, attr2_name: attr2_value }
instances.add_instance(attr_values)

Parameters:

  • instance_or_values (Instance, Array, Hash)

    the attribute values of the instance to be added. If passing an array, the attribute values must be in the same order as the attributes defined in Instances. If passing a hash, The keys are the names of the attributes and their values are corresponding attributes values.



226
227
228
229
# File 'lib/weka/core/instances.rb', line 226

def add_instance(instance_or_values, weight: 1.0)
  instance = instance_from(instance_or_values, weight: weight)
  add(instance)
end