net.sf.myra.datamining.data
Class Instance

java.lang.Object
  extended by net.sf.myra.datamining.data.Instance
All Implemented Interfaces:
java.io.Serializable

public final class Instance
extends java.lang.Object
implements java.io.Serializable

This class represents a instance of the dataset.

Version:
$Revision: 2298 $ $Date:: 2010-08-04 16:28:20#$
Author:
Fernando Esteban Barril Otero
See Also:
Dataset, Serialized Form

Field Summary
static double DEFAULT_WEIGHT
          The default weight of an instance.
 
Method Summary
 boolean belongs(java.lang.String label)
          Checks if the instance has the specified class label.
 boolean equals(Instance o)
          Compares the specified instance with this instance for equality.
 boolean equals(java.lang.Object o)
           
 int getIndex()
          Returns the instance index.
 Label getLabel()
          Returns the class label.
 Metadata getMetadata()
          Returns the Metadata object associated with this instance.
 java.lang.String getValue(Attribute attribute)
          Returns the instance value for the specified attribute.
 java.lang.String getValue(java.lang.String name)
          Returns the instance value for the specified attribute.
 java.lang.String[] getValues()
          Returns the instance values.
 double getWeight()
           
 int hashCode()
           
 boolean isLeaf()
          Verifies if this instance is associated with a leaf class label.
 boolean isMultilabel()
          Verifies if this is a multi-label instance.
 boolean[] labels()
          Returns the array of indexed class values (labels).
 void set(Attribute attribute, java.lang.String value)
          Sets the value of the specified attribute.
 void set(java.lang.String[] values)
          Sets all attributes values.
 void set(java.lang.String attribute, java.lang.String value)
          Sets the value of the specified attribute.
 void setWeight(double weight)
           
 java.lang.String toString()
           
 double value(int index)
          Return the (indexed) value of the specified attribute.
 double[] values()
          Returns the array of indexed values.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight of an instance.

See Also:
Constant Field Values
Method Detail

set

public void set(Attribute attribute,
                java.lang.String value)
Sets the value of the specified attribute.

Parameters:
attribute - the attribute to set the value.
value - the value to set.

set

public void set(java.lang.String attribute,
                java.lang.String value)
Sets the value of the specified attribute.

Parameters:
attribute - the attribute name to set the value.
value - the value to set.

set

public void set(java.lang.String[] values)
Sets all attributes values.

Parameters:
values - the array containing all attribute values.

getIndex

public int getIndex()
Returns the instance index.

Returns:
the instance index.

getValue

public java.lang.String getValue(Attribute attribute)
Returns the instance value for the specified attribute.

Parameters:
attribute - the attribute object.
Returns:
the instance value for the specified attribute.

getValue

public java.lang.String getValue(java.lang.String name)
Returns the instance value for the specified attribute.

Parameters:
name - the attribute name.
Returns:
the instance value for the specified attribute.

getValues

public java.lang.String[] getValues()
Returns the instance values.

Returns:
the instance values.

value

public double value(int index)
Return the (indexed) value of the specified attribute.

Parameters:
index - the attribute index.
Returns:
the (indexed) value of the specified attribute.

values

public final double[] values()
Returns the array of indexed values.

Returns:
the array of indexed values.

labels

public final boolean[] labels()
Returns the array of indexed class values (labels).

Returns:
the array of indexed class values (labels).

getLabel

public Label getLabel()
Returns the class label.

Returns:
the class label.

belongs

public boolean belongs(java.lang.String label)
Checks if the instance has the specified class label.

Parameters:
label - the label to check.
Returns:
true if the instance has the specified label; false otherwise.

getMetadata

public Metadata getMetadata()
Returns the Metadata object associated with this instance.

Returns:
the Metadata object associated with this instance.

isMultilabel

public boolean isMultilabel()
Verifies if this is a multi-label instance.

Returns:
true if this is a multi-label instance; false otherwise.

isLeaf

public boolean isLeaf()
Verifies if this instance is associated with a leaf class label.

Returns:
true if this instance is associated with a leaf class label; false otherwise.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(Instance o)
Compares the specified instance with this instance for equality. Returns true if the two instances have the same Metadata object and if the given instance have the same values.

Parameters:
o - the instance to be compared for equality with this instance.
Returns:
true if the specified instance is equal to this instance; false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getWeight

public double getWeight()
Returns:
the weight

setWeight

public void setWeight(double weight)
Parameters:
weight - the weight to set


Copyright © 2013. All Rights Reserved.