com.rapidminer.example.set
Class AttributeWeightedExampleSet

java.lang.Object
  extended by com.rapidminer.operator.AbstractIOObject
      extended by com.rapidminer.operator.ResultObjectAdapter
          extended by com.rapidminer.example.set.AbstractExampleSet
              extended by com.rapidminer.example.set.AttributeWeightedExampleSet
All Implemented Interfaces:
ExampleSet, IOObject, ResultObject, LoggingHandler, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Example>

public class AttributeWeightedExampleSet
extends AbstractExampleSet

An implementation of ExampleSet that allows the weighting of the attributes. Weights can be queried by the method getWeight(Attribute).

Author:
Ingo Mierswa ingomierswa Exp $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.rapidminer.operator.AbstractIOObject
AbstractIOObject.InputStreamProvider
 
Constructor Summary
  AttributeWeightedExampleSet(AttributeWeightedExampleSet exampleSet)
          Clone constructor.
protected AttributeWeightedExampleSet(ExampleSet exampleSet)
          Constructs a new AttributeWeightedExampleSet.
  AttributeWeightedExampleSet(ExampleSet exampleSet, AttributeWeights weights)
          Constructs a new AttributeWeightedExampleSet.
  AttributeWeightedExampleSet(ExampleSet exampleSet, AttributeWeights weights, double defaultWeight)
          Constructs a new AttributeWeightedExampleSet.
 
Method Summary
 AttributeWeightedExampleSet createCleanClone()
          Returns a clone where the zero weighted attributes are not delivered.
 DataTable createDataTable(IOContainer container)
          This method is used to create a DataTable from this example set.
 void deselectAll()
          Sets the weights of all attributes to 0.0.
 boolean equals(java.lang.Object o)
          Returns true, if all attributes including labels and other special attributes are equal.
 void flipAttributeUsed(Attribute attribute)
          Flips the selection state of the attribute with the given index.
 Attributes getAttributes()
          Returns the data structure holding all attributes.
 AttributeWeights getAttributeWeights()
           
 Example getExample(int index)
          Returns the i-th example.
 ExampleTable getExampleTable()
          Returns the underlying example table.
 int getNumberOfUsedAttributes()
          Returns the number of selected attributes.
 double getWeight(Attribute attribute)
          Returns the weight of the attribute.
 int hashCode()
          Returns the hash code of all attributes.
 boolean isAttributeUsed(Attribute attribute)
          Returns the selection state of the attribute.
 java.util.Iterator<Example> iterator()
          Creates a new example set reader.
 void selectAll()
          Sets the weights of all attributes to 1.0.
 void selectRandomSubset(int n, java.util.Random random)
          Randomly selects approximately the given number of attributes.
 void setAttributeUsed(Attribute attribute, boolean selected)
          Sets the selection state of the attribute.
 void setWeight(Attribute attribute, double weightValue)
          Sets the weight of the attribute.
 int size()
          Returns the number of examples in this example set.
 java.lang.String toString()
           
 
Methods inherited from class com.rapidminer.example.set.AbstractExampleSet
clone, copy, getExampleFromId, getExampleIndicesFromId, getExtension, getFileDescription, getName, getStatistics, getStatistics, recalculateAllAttributeStatistics, recalculateAttributeStatistics, remapIds, writeAttributeFile, writeDataFile, writeSparseAttributeFile, writeSparseDataFile
 
Methods inherited from class com.rapidminer.operator.ResultObjectAdapter
addAction, getActions, getAnnotations, getResultIcon, log, log, logError, logNote, logWarning, toHTML, toResultString
 
Methods inherited from class com.rapidminer.operator.AbstractIOObject
appendOperatorToHistory, getLog, getProcessingHistory, getSource, initWriting, read, read, read, read, setLoggingHandler, setSource, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rapidminer.operator.ResultObject
getActions, getResultIcon, toResultString
 
Methods inherited from interface com.rapidminer.operator.IOObject
appendOperatorToHistory, getAnnotations, getLog, getProcessingHistory, getSource, setLoggingHandler, setSource, write
 

Constructor Detail

AttributeWeightedExampleSet

protected AttributeWeightedExampleSet(ExampleSet exampleSet)
Constructs a new AttributeWeightedExampleSet. Initially all attributes are weighted with 1.0.


AttributeWeightedExampleSet

public AttributeWeightedExampleSet(ExampleSet exampleSet,
                                   AttributeWeights weights)
Constructs a new AttributeWeightedExampleSet. The attributes are weighted with the given weights. Attributes which are not stored in the map are weighted with 1.0.


AttributeWeightedExampleSet

public AttributeWeightedExampleSet(ExampleSet exampleSet,
                                   AttributeWeights weights,
                                   double defaultWeight)
Constructs a new AttributeWeightedExampleSet. The attributes are weighted with the given weights. Attributes which are not stored in the map are weighted with the given default weight.


AttributeWeightedExampleSet

public AttributeWeightedExampleSet(AttributeWeightedExampleSet exampleSet)
Clone constructor.

Method Detail

getAttributeWeights

public AttributeWeights getAttributeWeights()

createCleanClone

public AttributeWeightedExampleSet createCleanClone()
Returns a clone where the zero weighted attributes are not delivered.


getAttributes

public Attributes getAttributes()
Description copied from interface: ExampleSet
Returns the data structure holding all attributes.


getWeight

public double getWeight(Attribute attribute)
Returns the weight of the attribute.


setWeight

public void setWeight(Attribute attribute,
                      double weightValue)
Sets the weight of the attribute.


getNumberOfUsedAttributes

public int getNumberOfUsedAttributes()
Returns the number of selected attributes.


selectAll

public void selectAll()
Sets the weights of all attributes to 1.0.


deselectAll

public void deselectAll()
Sets the weights of all attributes to 0.0.


isAttributeUsed

public boolean isAttributeUsed(Attribute attribute)
Returns the selection state of the attribute.


setAttributeUsed

public void setAttributeUsed(Attribute attribute,
                             boolean selected)
Sets the selection state of the attribute.


flipAttributeUsed

public void flipAttributeUsed(Attribute attribute)
Flips the selection state of the attribute with the given index. (Convenience method for evolutionary algorithms). If a block starts with this attribute the whole block will be switched. Returns the index of the attribute which is the last one in the block or the index of the given attribute itself if it is not the start attribute of a block.


selectRandomSubset

public void selectRandomSubset(int n,
                               java.util.Random random)
Randomly selects approximately the given number of attributes. Will not throw an exception if the given number exceeds the current number of features. If no attributes would be selected a single attribute will be selected.


equals

public boolean equals(java.lang.Object o)
Description copied from class: AbstractExampleSet
Returns true, if all attributes including labels and other special attributes are equal.

Specified by:
equals in interface ExampleSet
Overrides:
equals in class AbstractExampleSet

hashCode

public int hashCode()
Description copied from class: AbstractExampleSet
Returns the hash code of all attributes.

Specified by:
hashCode in interface ExampleSet
Overrides:
hashCode in class AbstractExampleSet

toString

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

createDataTable

public DataTable createDataTable(IOContainer container)
Description copied from class: AbstractExampleSet
This method is used to create a DataTable from this example set. The default implementation returns an instance of DataTableExampleSetAdapter. The given IOContainer is used to check if there are compatible attribute weights which would used as column weights of the returned table. Subclasses might want to override this method in order to allow for other data tables.

Overrides:
createDataTable in class AbstractExampleSet

iterator

public java.util.Iterator<Example> iterator()
Creates a new example set reader.


getExample

public Example getExample(int index)
Description copied from interface: ExampleSet
Returns the i-th example. It is not guaranteed that asking for an example by using the index in the example table is efficiently implemented. Therefore for-loops for iterations are not an option and an ExampleReader should be used.


getExampleTable

public ExampleTable getExampleTable()
Description copied from interface: ExampleSet
Returns the underlying example table. Most operators should operate on the example set and manipulate example to change table data instead of using the table directly.


size

public int size()
Description copied from interface: ExampleSet
Returns the number of examples in this example set. This number should not be used to create for-loops to iterate through all examples.



Copyright © 2001-2009 by Rapid-I