net.sf.myra.datamining.data
Class NominalAttribute

java.lang.Object
  extended by net.sf.myra.datamining.data.Attribute
      extended by net.sf.myra.datamining.data.NominalAttribute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Attribute>

public class NominalAttribute
extends Attribute

This class represents a nominal attribute.

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

Field Summary
static int MISSING_VALUE_INDEX
          The index for missing values.
 
Constructor Summary
NominalAttribute(java.lang.String name)
          Creates a new NominalAttribute instance.
NominalAttribute(java.lang.String name, java.util.Collection<java.lang.String> values)
          Creates a new NominalAttribute instance.
NominalAttribute(java.lang.String name, java.lang.String[] values)
          Creates a new NominalAttribute instance.
 
Method Summary
 void add(java.lang.String value)
          Adds a value to the attrube domain.
 NominalAttribute clone()
           
 boolean equals(Attribute o)
           
 boolean equals(NominalAttribute o)
           
 int getIndex(java.lang.String value)
          Returns the index of the specified value.
 java.lang.String getValue(int index)
          Returns a value given its index.
 java.util.Collection<java.lang.String> getValues()
          Returns the values of the attribute.
 boolean isMissing(double value)
          Checks if the specified value corresponds to a missing value.
 java.lang.String modal(java.util.List<Instance> instances)
          Returns the most frequent (modal) value.
 void remove(java.lang.String value)
          Removes the specified value from the attribute domain.
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String value)
           
 void validate(java.lang.String value)
          Checks of the current value belongs to the attribute's domain.
 
Methods inherited from class net.sf.myra.datamining.data.Attribute
compareTo, equals, getName, hashCode, isTarget, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MISSING_VALUE_INDEX

public static final int MISSING_VALUE_INDEX
The index for missing values.

See Also:
Constant Field Values
Constructor Detail

NominalAttribute

public NominalAttribute(java.lang.String name)
Creates a new NominalAttribute instance.

Parameters:
name - the attribute name.

NominalAttribute

public NominalAttribute(java.lang.String name,
                        java.lang.String[] values)
Creates a new NominalAttribute instance.

Parameters:
name - the attribute name.
values - the attribute values.

NominalAttribute

public NominalAttribute(java.lang.String name,
                        java.util.Collection<java.lang.String> values)
Creates a new NominalAttribute instance.

Parameters:
name - the attribute name.
values - the attribute values.
Method Detail

add

public void add(java.lang.String value)
Adds a value to the attrube domain. The values are stored in alphabetic order.

Parameters:
value - the value to add.

remove

public void remove(java.lang.String value)
Removes the specified value from the attribute domain.

Parameters:
value - the value to remove.

getValues

public java.util.Collection<java.lang.String> getValues()
Returns the values of the attribute.

Returns:
the values of the attribute.

getIndex

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

Parameters:
value - the nominal attribute's value.
Returns:
the index of the specified value.

getValue

public java.lang.String getValue(int index)
Returns a value given its index.

Parameters:
index - the value's index.
Returns:
a value given its index.

toString

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

toString

public java.lang.String toString(java.lang.String value)

validate

public void validate(java.lang.String value)
Description copied from class: Attribute
Checks of the current value belongs to the attribute's domain.

Specified by:
validate in class Attribute
Parameters:
value - to value to check.

isMissing

public boolean isMissing(double value)
Description copied from class: Attribute
Checks if the specified value corresponds to a missing value.

Specified by:
isMissing in class Attribute
Parameters:
value - the value to check.
Returns:
true if the specified value corresponds to a missing value; false otherwise.

clone

public NominalAttribute clone()
Overrides:
clone in class Attribute

equals

public boolean equals(Attribute o)
Overrides:
equals in class Attribute

equals

public boolean equals(NominalAttribute o)

modal

public java.lang.String modal(java.util.List<Instance> instances)
Returns the most frequent (modal) value.

Parameters:
instances - the instances used to compute the modal.
Returns:
the most frequent (modal) value.


Copyright © 2013. All Rights Reserved.