com.rapidminer.example.table
Class AbstractExampleTable

java.lang.Object
  extended by com.rapidminer.example.table.AbstractExampleTable
All Implemented Interfaces:
ExampleTable, java.io.Serializable
Direct Known Subclasses:
DatabaseExampleTable, IndexCachedDatabaseExampleTable, LimitCachedDatabaseExampleTable, MemoryExampleTable, RandomExampleTable

public abstract class AbstractExampleTable
extends java.lang.Object
implements ExampleTable

This class is the core data supplier for example sets. Several example sets can use the same data and access the attribute values by reference.

Author:
Ingo Mierswa
See Also:
Serialized Form

Constructor Summary
AbstractExampleTable(java.util.List<Attribute> attributes)
          Creates a new ExampleTable.
 
Method Summary
 int addAttribute(Attribute a)
          Adds the attribute to the list of attributes assigning it a free column index.
 void addAttributes(java.util.Collection<Attribute> newAttributes)
          Adds all Attributes in newAttributes to the end of the list of attributes, creating new data columns if necessary.
 ExampleSet createExampleSet()
          Returns a new example set with all attributes switched on.
 ExampleSet createExampleSet(Attribute labelAttribute)
          Returns a new example set with all attributes switched on.
 ExampleSet createExampleSet(Attribute labelAttribute, Attribute weightAttribute, Attribute idAttribute)
          Returns a new example set with all attributes switched on.
 ExampleSet createExampleSet(AttributeSet attributeSet)
          Returns a new example set with all attributes of the ExampleTable and with the special roles defined by the given attribute set.
 ExampleSet createExampleSet(java.util.Iterator<AttributeRole> newSpecialAttributes)
          Returns a new example set with all attributes switched on.
 ExampleSet createExampleSet(java.util.Map<Attribute,java.lang.String> specialAttributes)
          Returns a new example set with all attributes switched on.
 Attribute findAttribute(java.lang.String name)
          Returns the attribute with the given name.
 Attribute getAttribute(int i)
          Returns the attribute of the column number i.
 int getAttributeCount()
          Returns the number of non null attributes.
 Attribute[] getAttributes()
          Returns a new array containing all Attributes.
 int getNumberOfAttributes()
          Returns the number of attributes.
 void removeAttribute(Attribute attribute)
          Equivalent to calling removeAttribute(attribute.getTableIndex()).
 void removeAttribute(int index)
          Sets the attribute with the given index to null.
 java.lang.String toDataString()
          Dumps the complete data as string.
 java.lang.String toString()
          Returns a string representation of this example table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rapidminer.example.table.ExampleTable
getDataRow, getDataRowReader, size
 

Constructor Detail

AbstractExampleTable

public AbstractExampleTable(java.util.List<Attribute> attributes)
Creates a new ExampleTable.

Parameters:
attributes - List of Attribute. The indices of the attibutes are set to values reflecting their position in the list.
Method Detail

getAttributes

public Attribute[] getAttributes()
Returns a new array containing all Attributes.

Specified by:
getAttributes in interface ExampleTable

getAttribute

public Attribute getAttribute(int i)
Returns the attribute of the column number i. Attention: This value may return null if the column was marked unused.

Specified by:
getAttribute in interface ExampleTable

findAttribute

public Attribute findAttribute(java.lang.String name)
                        throws OperatorException
Returns the attribute with the given name.

Specified by:
findAttribute in interface ExampleTable
Throws:
OperatorException

addAttributes

public void addAttributes(java.util.Collection<Attribute> newAttributes)
Adds all Attributes in newAttributes to the end of the list of attributes, creating new data columns if necessary.

Specified by:
addAttributes in interface ExampleTable

addAttribute

public int addAttribute(Attribute a)
Adds the attribute to the list of attributes assigning it a free column index. If the name is already in use, the attribute will be renamed.

Specified by:
addAttribute in interface ExampleTable

removeAttribute

public void removeAttribute(Attribute attribute)
Equivalent to calling removeAttribute(attribute.getTableIndex()).

Specified by:
removeAttribute in interface ExampleTable

removeAttribute

public void removeAttribute(int index)
Sets the attribute with the given index to null. Afterwards, this column can be reused. Callers must make sure, that no other example set contains a reference to this column. Otherwise its data will be messed up. Usually this is only possible if an operator generates intermediate attributes, like a validation chain or a feature generator. If the attribute already was removed, this method returns silently.

Specified by:
removeAttribute in interface ExampleTable

getNumberOfAttributes

public int getNumberOfAttributes()
Returns the number of attributes. Attention: Callers that use a for-loop and retrieving Attributes by calling getAttribute(int) must keep in mind, that some of these attributes may be null.

Specified by:
getNumberOfAttributes in interface ExampleTable

getAttributeCount

public int getAttributeCount()
Returns the number of non null attributes. Attention: Since there are null attributes in the list, the return value of this method must not be used in a for-loop!

Specified by:
getAttributeCount in interface ExampleTable
See Also:
ExampleTable.getNumberOfAttributes().

createExampleSet

public ExampleSet createExampleSet(Attribute labelAttribute)
Returns a new example set with all attributes switched on. The given attribute will be used as a special label attribute for learning.

Specified by:
createExampleSet in interface ExampleTable

createExampleSet

public ExampleSet createExampleSet(Attribute labelAttribute,
                                   Attribute weightAttribute,
                                   Attribute idAttribute)
Returns a new example set with all attributes switched on. The given attributes will be used as a special label attribute for learning, as (example) weight attribute, and as id attribute.

Specified by:
createExampleSet in interface ExampleTable

createExampleSet

public ExampleSet createExampleSet(java.util.Iterator<AttributeRole> newSpecialAttributes)
Returns a new example set with all attributes switched on. The iterator over the attribute roles will define the special attributes.

Specified by:
createExampleSet in interface ExampleTable

createExampleSet

public ExampleSet createExampleSet(AttributeSet attributeSet)
Returns a new example set with all attributes of the ExampleTable and with the special roles defined by the given attribute set.

Specified by:
createExampleSet in interface ExampleTable

createExampleSet

public ExampleSet createExampleSet()
Returns a new example set with all attributes switched on. All attributes given at creation time will be regular.

Specified by:
createExampleSet in interface ExampleTable

createExampleSet

public ExampleSet createExampleSet(java.util.Map<Attribute,java.lang.String> specialAttributes)
Returns a new example set with all attributes switched on. The attributes in the given map will be used as special attributes with the specified names, all other attributes given at creation time will be regular.

Specified by:
createExampleSet in interface ExampleTable

toString

public java.lang.String toString()
Description copied from interface: ExampleTable
Returns a string representation of this example table.

Specified by:
toString in interface ExampleTable
Overrides:
toString in class java.lang.Object

toDataString

public java.lang.String toDataString()
Description copied from interface: ExampleTable
Dumps the complete data as string.

Specified by:
toDataString in interface ExampleTable


Copyright © 2001-2009 by Rapid-I