com.rapidminer.example.table
Class BinominalMapping

java.lang.Object
  extended by com.rapidminer.example.table.BinominalMapping
All Implemented Interfaces:
NominalMapping, java.io.Serializable, java.lang.Cloneable

public class BinominalMapping
extends java.lang.Object
implements NominalMapping

This is an efficient implementation of a NominalMapping which can be used for binominal attributes, i.e. for attributes with only two different values.

Author:
Ingo Mierswa
See Also:
Serialized Form

Constructor Summary
BinominalMapping()
           
 
Method Summary
 void clear()
          Clears all mappings for nominal values.
 java.lang.Object clone()
          Should return a deep clone of this nominal mapping.
 int getIndex(java.lang.String str)
          Returns the index of the given nominal value or -1 if this value was not mapped before by invoking the method mapIndex(int).
 int getNegativeIndex()
          Returns the index of the first value if this attribute is a classification attribute, i.e. if it is binominal.
 java.lang.String getNegativeString()
          Returns the nominal value of a negative class (if available).
 int getPositiveIndex()
          Returns the index of the second value if this attribute is a classification attribute.
 java.lang.String getPositiveString()
          Returns the nominal value of a positive class (if available).
 java.util.List<java.lang.String> getValues()
          Returns the values of the attribute as an enumeration of strings.
 java.lang.String mapIndex(int index)
          Returns the attribute value, that is associated with this index.
 int mapString(java.lang.String str)
          Returns the index for the nominal attribute value str.
 void setMapping(java.lang.String nominalValue, int index)
          Sets the given mapping.
 int size()
          Returns the number of different nominal values.
 void sortMappings()
          This method rearranges the string to number mappings such that they are in alphabetical order.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinominalMapping

public BinominalMapping()
Method Detail

clone

public java.lang.Object clone()
Description copied from interface: NominalMapping
Should return a deep clone of this nominal mapping.

Specified by:
clone in interface NominalMapping
Overrides:
clone in class java.lang.Object

mapString

public int mapString(java.lang.String str)
Returns the index for the nominal attribute value str. If the string is unknown, a new index value is assigned. Returns -1, if str is null.

Specified by:
mapString in interface NominalMapping

getIndex

public int getIndex(java.lang.String str)
Returns the index of the given nominal value or -1 if this value was not mapped before by invoking the method mapIndex(int).

Specified by:
getIndex in interface NominalMapping

mapIndex

public java.lang.String mapIndex(int index)
Returns the attribute value, that is associated with this index. Index counting starts with 0. WARNING: In order to iterate over all values please use the collection returned by getValues().

Specified by:
mapIndex in interface NominalMapping

setMapping

public void setMapping(java.lang.String nominalValue,
                       int index)
Sets the given mapping. Please note that this will overwrite existing mappings and might cause data changes in this way.

Specified by:
setMapping in interface NominalMapping

getNegativeIndex

public int getNegativeIndex()
Returns the index of the first value if this attribute is a classification attribute, i.e. if it is binominal.

Specified by:
getNegativeIndex in interface NominalMapping

getPositiveIndex

public int getPositiveIndex()
Returns the index of the second value if this attribute is a classification attribute. Works for all binominal attributes.

Specified by:
getPositiveIndex in interface NominalMapping

getNegativeString

public java.lang.String getNegativeString()
Description copied from interface: NominalMapping
Returns the nominal value of a negative class (if available). Returns null otherwise.

Specified by:
getNegativeString in interface NominalMapping

getPositiveString

public java.lang.String getPositiveString()
Description copied from interface: NominalMapping
Returns the nominal value of a positive class (if available). Returns null otherwise.

Specified by:
getPositiveString in interface NominalMapping

getValues

public java.util.List<java.lang.String> getValues()
Returns the values of the attribute as an enumeration of strings.

Specified by:
getValues in interface NominalMapping

size

public int size()
Returns the number of different nominal values.

Specified by:
size in interface NominalMapping

sortMappings

public void sortMappings()
This method rearranges the string to number mappings such that they are in alphabetical order.
VERY IMPORTANT NOTE: Do not call this method when this attribute is already associated with an AbstractExampleTable and it already contains Examples. All examples will be messed up!

Specified by:
sortMappings in interface NominalMapping

clear

public void clear()
Clears all mappings for nominal values.

Specified by:
clear in interface NominalMapping


Copyright © 2001-2009 by Rapid-I