com.rapidminer.example
Class AttributeWeights

java.lang.Object
  extended by com.rapidminer.operator.AbstractIOObject
      extended by com.rapidminer.operator.ResultObjectAdapter
          extended by com.rapidminer.tools.math.AverageVector
              extended by com.rapidminer.example.AttributeWeights
All Implemented Interfaces:
IOObject, ResultObject, Saveable, LoggingHandler, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class AttributeWeights
extends AverageVector

AttributeWeights holds the information about the weights of attributes of an example set. It is delivered by several feature weighting algorithms or learning schemes. The use of a linked hash map ensures that the added features are stored in the same sequence they were added.

Author:
Ingo Mierswa Exp $
See Also:
Serialized Form

Field Summary
static int ABSOLUTE_WEIGHTS
          Indicates that the the absolute weights should be used for sorting.
static int DECREASING
          Indicates that the weights should be sorted in descending order.
static int INCREASING
          Indicates that the weights should be sorted in ascending order.
static int NO_SORTING
          Indicates that the weights should not be sorted at all.
static int ORIGINAL_WEIGHTS
          Indicates that the the actual weights should be used for sorting.
 
Constructor Summary
AttributeWeights()
          Creates a new empty attribute weights object.
AttributeWeights(ExampleSet exampleSet)
          Creates a new attribute weights object containing a weight of 1 for each of the given input attributes.
 
Method Summary
 java.lang.Object clone()
          Returns a deep clone of the attribute weights which provides the same sequence of attribute names.
 int compareTo(java.lang.Object o)
          Since this average vector cannot be compared this method always returns 0.
 DataTable createDataTable()
           
 boolean equals(java.lang.Object o)
          Returns true if both objects have the same weight map.
 java.util.Set<java.lang.String> getAttributeNames()
          Returns an set of attribute names in this map ordered by their insertion time.
 java.lang.String getExtension()
          Returns the default extension in file choosers.
 java.lang.String getFileDescription()
          Returns the file description used in file choosers.
 java.lang.String getName()
          Returns the name of this AverageVector.
 javax.swing.Icon getResultIcon()
          Returns null.
 int getSortingType()
          Returns the currently used sorting type.
 java.awt.Component getVisualizationComponent(IOContainer container)
          Returns a visualisation component which allows sorting of the attribute weights and several weight plots.
 double getWeight(java.lang.String name)
          Returns the weight for the attribute with the given name.
 int getWeightType()
          Returns the currently used weight type.
 int hashCode()
          Returns the hash code of the weight map.
static AttributeWeights load(java.io.File file)
          Loads a new AttributeWeights object from the given XML file.
 void normalize()
          This method normalizes all weights to the range 0 to 1.
 void save(java.io.File file)
          Saves the attribute weights into an XML file.
 void setSortingType(int sortingType)
          Sets the currently used sorting type.
 void setWeight(java.lang.String name, double weight)
          Sets the weight for the attribute with the given name.
 void setWeightType(int weightType)
          Returns the currently used weight type.
 int size()
          Returns the number of features in this map.
 void sortByWeight(java.lang.String[] attributeNames, int direction, int comparatorType)
          Sorts the given array of attribute names according to their weight, the sorting direction (ascending or descending), and with respect to the fact if original or absolute weights should be used.
 java.lang.String toString()
          Returns a string representation of this object.
 void writeAttributeWeights(java.io.File file, java.nio.charset.Charset encoding)
           
 
Methods inherited from class com.rapidminer.tools.math.AverageVector
addAveragable, buildAverages, getAveragable, getAveragable, getSize, removeAveragable, toResultString
 
Methods inherited from class com.rapidminer.operator.ResultObjectAdapter
addAction, getActions, isSavable, log, logError, logNote, logWarning, toHTML
 
Methods inherited from class com.rapidminer.operator.AbstractIOObject
copy, getLog, getSource, initWriting, 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.IOObject
copy, getLog, getSource, setLoggingHandler, setSource, write
 

Field Detail

NO_SORTING

public static final int NO_SORTING
Indicates that the weights should not be sorted at all.

See Also:
Constant Field Values

DECREASING

public static final int DECREASING
Indicates that the weights should be sorted in descending order.

See Also:
Constant Field Values

INCREASING

public static final int INCREASING
Indicates that the weights should be sorted in ascending order.

See Also:
Constant Field Values

ORIGINAL_WEIGHTS

public static final int ORIGINAL_WEIGHTS
Indicates that the the actual weights should be used for sorting.

See Also:
Constant Field Values

ABSOLUTE_WEIGHTS

public static final int ABSOLUTE_WEIGHTS
Indicates that the the absolute weights should be used for sorting.

See Also:
Constant Field Values
Constructor Detail

AttributeWeights

public AttributeWeights()
Creates a new empty attribute weights object.


AttributeWeights

public AttributeWeights(ExampleSet exampleSet)
Creates a new attribute weights object containing a weight of 1 for each of the given input attributes.

Method Detail

getName

public java.lang.String getName()
Returns the name of this AverageVector.

Specified by:
getName in interface ResultObject
Overrides:
getName in class ResultObjectAdapter

setWeight

public void setWeight(java.lang.String name,
                      double weight)
Sets the weight for the attribute with the given name.


getWeight

public double getWeight(java.lang.String name)
Returns the weight for the attribute with the given name. Returns Double.NaN if the weight for the queried attribute is not known.


getWeightType

public int getWeightType()
Returns the currently used weight type.


setWeightType

public void setWeightType(int weightType)
Returns the currently used weight type.


getSortingType

public int getSortingType()
Returns the currently used sorting type.


setSortingType

public void setSortingType(int sortingType)
Sets the currently used sorting type.


size

public int size()
Returns the number of features in this map.

Overrides:
size in class AverageVector

getAttributeNames

public java.util.Set<java.lang.String> getAttributeNames()
Returns an set of attribute names in this map ordered by their insertion time.


compareTo

public int compareTo(java.lang.Object o)
Since this average vector cannot be compared this method always returns 0.


equals

public boolean equals(java.lang.Object o)
Returns true if both objects have the same weight map.

Overrides:
equals in class AverageVector

hashCode

public int hashCode()
Returns the hash code of the weight map.

Overrides:
hashCode in class AverageVector

sortByWeight

public void sortByWeight(java.lang.String[] attributeNames,
                         int direction,
                         int comparatorType)
Sorts the given array of attribute names according to their weight, the sorting direction (ascending or descending), and with respect to the fact if original or absolute weights should be used.

Parameters:
direction - ASCENDING or DESCENDING
comparatorType - WEIGHT or WEIGHT_ABSOLUTE.

save

public void save(java.io.File file)
          throws java.io.IOException
Saves the attribute weights into an XML file.

Specified by:
save in interface Saveable
Overrides:
save in class ResultObjectAdapter
Throws:
java.io.IOException

writeAttributeWeights

public void writeAttributeWeights(java.io.File file,
                                  java.nio.charset.Charset encoding)
                           throws java.io.IOException
Throws:
java.io.IOException

load

public static AttributeWeights load(java.io.File file)
                             throws java.io.IOException
Loads a new AttributeWeights object from the given XML file.

Throws:
java.io.IOException

getExtension

public java.lang.String getExtension()
Description copied from interface: Saveable
Returns the default extension in file choosers.


getFileDescription

public java.lang.String getFileDescription()
Description copied from interface: Saveable
Returns the file description used in file choosers.


toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class AverageVector

clone

public java.lang.Object clone()
Returns a deep clone of the attribute weights which provides the same sequence of attribute names.

Specified by:
clone in class AverageVector

normalize

public void normalize()
This method normalizes all weights to the range 0 to 1.


getVisualizationComponent

public java.awt.Component getVisualizationComponent(IOContainer container)
Returns a visualisation component which allows sorting of the attribute weights and several weight plots.

Specified by:
getVisualizationComponent in interface ResultObject
Overrides:
getVisualizationComponent in class AverageVector

getResultIcon

public javax.swing.Icon getResultIcon()
Description copied from class: ResultObjectAdapter
Returns null. Subclasses might want to override this method and returns an appropriate icon.

Specified by:
getResultIcon in interface ResultObject
Overrides:
getResultIcon in class ResultObjectAdapter

createDataTable

public DataTable createDataTable()


Copyright © 2001-2009 by Rapid-I