net.sf.myra.datamining.data
Class Label

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

public class Label
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class represents a label for an instance. The label is represented as an array of all possible labels. Note that for hierarchical and multi-label problems, where more than one label can be associated with an instance, the array can have more than one position active.

Version:
$Revision$ $Date:: $
Author:
Fernando Esteban Barril Otero
See Also:
Serialized Form

Method Summary
 boolean active(int index)
          Returns true is the specified class label index is active.
 boolean active(java.lang.String value)
          Returns true is the specified class label is active.
 int cardinality()
          Returns the number of class labels present in this Label instance.
 boolean contains(Label label)
          Returns true if this label contains all values of the specified label.
 boolean equals(Label o)
          Indicates whether the specified Label instance is equal to this one.
 boolean equals(java.lang.Object o)
           
 boolean[] flags()
          Returns the array representation of this label.
 java.lang.String get(int index)
          Returns the class label name specified by the index.
 int getIndex(java.lang.String value)
          Returns the index of the specified class value.
 java.util.Collection<java.lang.String> getValues()
          Returns the collection of class label values that are set for this instance.
 int hashCode()
           
 int intersect(Label another)
          Returns the number of class labels that are present in both Label instances.
 int length()
          Returns the label length.
 java.lang.String[] names()
          Returns the names array of this label.
 Label toLabel(boolean[] flags)
          Returns a new Label instance representing the specified array of flags.
 Label toLabel(java.util.Collection<java.lang.String> labels)
          Returns a new Label instance representing the specified list of labels.
 Label toLabel(java.lang.String... values)
          Returns a new Label instance representing the specified array of labels.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

length

public int length()
Returns the label length.

Returns:
the label length.

toLabel

public Label toLabel(java.lang.String... values)
Returns a new Label instance representing the specified array of labels.

Parameters:
values - the array of labels.
Returns:
a new Label instance representing the specified array of labels.

toLabel

public Label toLabel(java.util.Collection<java.lang.String> labels)
Returns a new Label instance representing the specified list of labels.

Parameters:
labels - the list of labels.
Returns:
a new Label instance representing the specified list of labels.

toLabel

public Label toLabel(boolean[] flags)
Returns a new Label instance representing the specified array of flags.

Parameters:
flags - the array of flags.
Returns:
a new Label instance representing the specified array of flags.

equals

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

equals

public boolean equals(Label o)
Indicates whether the specified Label instance is equal to this one.

Parameters:
o - the Label instance with which to compare.
Returns:
true if this instance is the same as the o argument; false otherwise.

toString

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

getValues

public java.util.Collection<java.lang.String> getValues()
Returns the collection of class label values that are set for this instance.

Returns:
the collection of class label values that are set for this instance.

active

public boolean active(int index)
Returns true is the specified class label index is active.

Parameters:
index - the class label index.
Returns:
true if class label is active; false otherwise.

active

public boolean active(java.lang.String value)
Returns true is the specified class label is active.

Parameters:
value - the class label.
Returns:
true if class label is active; false otherwise.

get

public java.lang.String get(int index)
Returns the class label name specified by the index.

Parameters:
index - the class label index.
Returns:
the class label name specified by the index.

getIndex

public int getIndex(java.lang.String value)
Returns the index of the specified class value.

Parameters:
value - the desired class value.
Returns:
the index of the specified class value.

intersect

public int intersect(Label another)
Returns the number of class labels that are present in both Label instances.

Parameters:
another - the label to check against.
Returns:
the number of class labels that are present in both Label instances.

cardinality

public int cardinality()
Returns the number of class labels present in this Label instance.

Returns:
the number of class labels present in this Label instance.

contains

public boolean contains(Label label)
Returns true if this label contains all values of the specified label.

Parameters:
label - the label to get the values from.
Returns:
true if this label contains all values of the specified label; false otherwise.

hashCode

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

flags

public boolean[] flags()
Returns the array representation of this label.

Returns:
the array representation of this label.

names

public java.lang.String[] names()
Returns the names array of this label.

Returns:
the names array of this label.


Copyright © 2013. All Rights Reserved.