com.rapidminer.example.table
Interface ExampleTable

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractExampleTable, DatabaseExampleTable, IndexCachedDatabaseExampleTable, LimitCachedDatabaseExampleTable, MemoryExampleTable, RandomExampleTable

public interface ExampleTable
extends java.io.Serializable

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. Thats means that ExampleTable contains all data like in a database management systems and all ExampleSets are only views on the data. The ExampleSets themself do hence not contain any data rows and can be cloned without copying the data.

Changing the data in the ExampleTable will change the data for all views (ExampleSets). On the other hand, the changes for one view (ExampleSet) like adding or removing Attributes will not change the ExampleTable and will also not change other views (ExampleSets).

Author:
Ingo Mierswa

Method Summary
 int addAttribute(Attribute a)
          Adds a clone of the attribute a 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)
           
 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.
 DataRow getDataRow(int index)
          Returns the i-th data row.
 DataRowReader getDataRowReader()
          Returns an Iterator for example data given as DataRow objects.
 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.
 int size()
          Returns the number of examples.
 java.lang.String toDataString()
          Dumps the complete data as string.
 java.lang.String toString()
          Returns a string representation of this example table.
 

Method Detail

size

int size()
Returns the number of examples.


getDataRowReader

DataRowReader getDataRowReader()
Returns an Iterator for example data given as DataRow objects. This should be used in all cases where iteration is desired. Since getDataRow(int) does not ensure to work in an efficient way the usage of this method is preferred (instead using for-loops).


getDataRow

DataRow getDataRow(int index)
Returns the i-th data row. Calling methods cannot rely on the efficiency of this method. Memory based example tables should return the data row in O(1).


getAttributes

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


getAttribute

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


findAttribute

Attribute findAttribute(java.lang.String name)
                        throws OperatorException
Returns the attribute with the given name. CAUTION: This does only return the first attribute found with this name. Since there is no guarantee that names are unique, this might not deliver the desired result.

Throws:
OperatorException

addAttributes

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.


addAttribute

int addAttribute(Attribute a)
Adds a clone of the attribute a to the list of attributes assigning it a free column index. The column index is also set on a.


removeAttribute

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


removeAttribute

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.


getNumberOfAttributes

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


getAttributeCount

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

See Also:
getNumberOfAttributes().

createExampleSet

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.


createExampleSet

ExampleSet createExampleSet(java.util.Iterator<AttributeRole> newSpecialAttributes)

createExampleSet

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.


createExampleSet

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.


createExampleSet

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, all other attributes given at creation time will be regular.


createExampleSet

ExampleSet createExampleSet()
Returns a new example set with all attributes switched on. All attributes will be used as regular attributes.


toString

java.lang.String toString()
Returns a string representation of this example table.

Overrides:
toString in class java.lang.Object

toDataString

java.lang.String toDataString()
Dumps the complete data as string.



Copyright © 2001-2009 by Rapid-I