javax.datamining.data
Interface CategorySet


public interface CategorySet

CategorySet contains a set of categorical values that constitute a categorical attribute, cost matrix, confusion matrix, etc. Each category exists at an index from 0 to N-1, where N is the cardinality of the set. To have NULL be a valid value, it must be explicitly assigned or use the default property of "valid". To have NULL as a missig value, it must be explicitly identified as "missing".

Author:
JSR-73 Java Data Mining Expert Group

Method Summary
 int addCategory(java.lang.Object categoryValue, CategoryProperty property)
          Adds a categorical value to the set and returns an index that is to be used to refer to the value.
 AttributeDataType getDataType()
          Returns the data type of the categorical values in the set.
 CategoryProperty getDefaultProperty()
          Returns the default property of unspecified categorical values that are not contained in the set.
 java.lang.Integer getIndex(java.lang.Object categoryValue)
          Returns the index of the categorical value.
 java.lang.String getName(int index)
          Returns the name of the categorical value with the specified index.
 CategoryProperty getProperty(int index)
          Returns the property of the categorical value with the specified index.
 int getSize()
          Returns the number of categories in the set.
 java.lang.Object getValue(int index)
          Returns the categorical value with the specified index.
 java.lang.Object[] getValues()
          Returns all categorical values contained in the set.
 java.lang.Object[] getValues(CategoryProperty property)
          Returns the list of all values with the given property.
 void insertCategory(java.lang.Object categoryValue, CategoryProperty property, int beforeIndex)
          Inserts the given category value and property before the given index in the set.
 void removeCategory(int index)
          Removes the categorical value refered to by the specified index.
 void setDefaultProperty(CategoryProperty property)
          Sets the default property of unspecified categorical values that are not contained in the set.
 void setName(int index, java.lang.String categoryName)
          Sets the name of the category specified by the index.
 

Method Detail

addCategory

public int addCategory(java.lang.Object categoryValue,
                       CategoryProperty property)
                throws JDMException
Adds a categorical value to the set and returns an index that is to be used to refer to the value.

Parameters:
categoryValue - A categorical value to be added.
property -
Returns:
int
Throws:
JDMException

getDataType

public AttributeDataType getDataType()
Returns the data type of the categorical values in the set.

Returns:
AttributeDataType

getDefaultProperty

public CategoryProperty getDefaultProperty()
Returns the default property of unspecified categorical values that are not contained in the set. The initial default is valid.

Returns:
CategoryProperty

getIndex

public java.lang.Integer getIndex(java.lang.Object categoryValue)
                           throws JDMException
Returns the index of the categorical value. Returns null if the value is not included in the set.

Parameters:
categoryValue - A categorical value whose index is to be returned.
Returns:
Integer
Throws:
JDMException

getName

public java.lang.String getName(int index)
Returns the name of the categorical value with the specified index. Returns null if no name is associated with the specified categorical value.

Names need not be unique within the set.

Parameters:
index - The index of the categorical value whose name is to be returned.
Returns:
String

getProperty

public CategoryProperty getProperty(int index)
Returns the property of the categorical value with the specified index.

Parameters:
index - The index of the categorical value whose property is to be returned.
Returns:
CategoryProperty

getSize

public int getSize()
Returns the number of categories in the set.

Returns:
int

getValue

public java.lang.Object getValue(int index)
Returns the categorical value with the specified index.

Parameters:
index - The index of the categorical value to be returned.
Returns:
Object

getValues

public java.lang.Object[] getValues()
Returns all categorical values contained in the set.

Returns:
Object[]

getValues

public java.lang.Object[] getValues(CategoryProperty property)
                             throws JDMException
Returns the list of all values with the given property. The indexes of the returned list need not to be identical to the source indexes.

Parameters:
property -
Returns:
Object[]
Throws:
JDMException

insertCategory

public void insertCategory(java.lang.Object categoryValue,
                           CategoryProperty property,
                           int beforeIndex)
                    throws JDMException
Inserts the given category value and property before the given index in the set. All categories with indexes J>=I before the call have a shifted index of J+1 after the call.

Parameters:
categoryValue -
property -
beforeIndex -
Returns:
void
Throws:
JDMException

removeCategory

public void removeCategory(int index)
                    throws JDMException
Removes the categorical value refered to by the specified index. All higher indexes are lowered by one. Ordering is maintained after removal.

A subsequent call of getValue(index) or getProperty(index) will return the value delivered by getValue(index+1) or getProperty(index+1), respectively.

Parameters:
index - The index of the categorical value to be removed.
Returns:
void
Throws:
JDMException

setDefaultProperty

public void setDefaultProperty(CategoryProperty property)
Sets the default property of unspecified categorical values that are not contained in the set. A null value indicates that no default property has to be used.

Parameters:
property - The default property of the unknown categorical values.
Returns:
void

setName

public void setName(int index,
                    java.lang.String categoryName)
Sets the name of the category specified by the index. The name can be used as the label (or display name) for the category.

Parameters:
index -
categoryName -
Returns:
void