com.rapidminer.example
Class Tools

java.lang.Object
  extended by com.rapidminer.example.Tools

public class Tools
extends java.lang.Object

Provides some tools for calculation of certain measures and feature generation.

Author:
Simon Fischer, Ingo Mierswa

Constructor Summary
Tools()
           
 
Method Summary
static void checkAndCreateIds(ExampleSet es)
          The example set has to have ids.
static boolean compatible(Attribute first, Attribute second)
          Returns true if value and block types of the first attribute are subtypes of value and block type of the second.
static boolean containsValueType(ExampleSet exampleSet, int valueType)
           
static Attribute[] createRegularAttributeArray(ExampleSet exampleSet)
           
static Attribute createSpecialAttribute(ExampleSet exampleSet, java.lang.String name, int valueType)
           
static Attribute createWeightAttribute(ExampleSet exampleSet)
           
static void fillTableWithRandomValues(ExampleTable exampleTable, ExampleSet baseSet, RandomGenerator random)
          After creation of a new MemoryExampleTable with given size all values are Double.NaN.
static java.lang.String[] getAllAttributeNames(ExampleSet exampleSet)
           
static double getAverageWeight(AttributeWeightedExampleSet exampleSet)
           
static double[] getInverseProbabilitiesFromWeights(Attribute[] attributes, AttributeWeightedExampleSet exampleSet)
           
static ExampleSet getLinearSubsetCopy(ExampleSet exampleSet, int size, int offset)
          Returns a new example set based on a fresh memory example table sampled from the given set.
static double[] getProbabilitiesFromWeights(Attribute[] attributes, AttributeWeightedExampleSet exampleSet)
           
static double[] getProbabilitiesFromWeights(Attribute[] attributes, AttributeWeightedExampleSet exampleSet, boolean inverse)
          Calculates probabilities for attribute selection purposes based on the given weight.
static Attribute[] getRandomCompatibleAttributes(ExampleSet exampleSet, FeatureGenerator generator, java.lang.String[] functions, java.util.Random random)
           
static java.lang.String[] getRegularAttributeConstructions(ExampleSet exampleSet)
           
static java.lang.String[] getRegularAttributeNames(ExampleSet exampleSet)
           
static ExampleSet getShuffledSubsetCopy(ExampleSet exampleSet, int size, RandomGenerator randomGenerator)
          Returns a new example set based on a fresh memory example table sampled from the given set.
static Attribute[] getWeightedCompatibleAttributes(AttributeWeightedExampleSet exampleSet, FeatureGenerator generator, java.lang.String[] functions, RandomGenerator random)
           
static void hasNominalLabels(ExampleSet es)
          The example set has to have nominal labels.
static boolean isDefault(double defaultValue, double value)
           
static void isIdTagged(ExampleSet es)
          The example set has to be tagged with ids.
static void isLabelled(ExampleSet es)
          The example set has to contain labels.
static void isNonEmpty(ExampleSet es)
          The example set has to contain at least one example.
static void onlyNominalAttributes(ExampleSet es, java.lang.String task)
          The attributes all have to be nominal or binary.
static void onlyNonMissingValues(ExampleSet exampleSet, java.lang.String task)
          The data set is not allowed to contain missing values.
static void onlyNumericalAttributes(ExampleSet es, java.lang.String task)
          The attributes all have to be numerical.
static void replaceValue(Attribute attribute, java.lang.String oldValue, java.lang.String newValue)
          Replaces the given real value by the new one.
static void replaceValue(ExampleSet exampleSet, Attribute attribute, double oldValue, double newValue)
          Replaces the given real value by the new one.
static void replaceValue(ExampleSet exampleSet, Attribute attribute, java.lang.String oldValue, java.lang.String newValue)
          Replaces the given value by the new one.
static Attribute selectAttribute(Attribute[] attributes, double[] probs, java.util.Random random)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tools

public Tools()
Method Detail

fillTableWithRandomValues

public static void fillTableWithRandomValues(ExampleTable exampleTable,
                                             ExampleSet baseSet,
                                             RandomGenerator random)
After creation of a new MemoryExampleTable with given size all values are Double.NaN. Use this method to fill the table with random values in the range specified by minimum and maximum values of the attributes. Please note that the attributes in the example table must already have proper minimum and maximum values. This works only for numerical attribute. Nominal attribute values will be set to 0.


getAllAttributeNames

public static java.lang.String[] getAllAttributeNames(ExampleSet exampleSet)

getRegularAttributeNames

public static java.lang.String[] getRegularAttributeNames(ExampleSet exampleSet)

getRegularAttributeConstructions

public static java.lang.String[] getRegularAttributeConstructions(ExampleSet exampleSet)

createRegularAttributeArray

public static Attribute[] createRegularAttributeArray(ExampleSet exampleSet)

getRandomCompatibleAttributes

public static Attribute[] getRandomCompatibleAttributes(ExampleSet exampleSet,
                                                        FeatureGenerator generator,
                                                        java.lang.String[] functions,
                                                        java.util.Random random)

getWeightedCompatibleAttributes

public static Attribute[] getWeightedCompatibleAttributes(AttributeWeightedExampleSet exampleSet,
                                                          FeatureGenerator generator,
                                                          java.lang.String[] functions,
                                                          RandomGenerator random)

createSpecialAttribute

public static Attribute createSpecialAttribute(ExampleSet exampleSet,
                                               java.lang.String name,
                                               int valueType)

createWeightAttribute

public static Attribute createWeightAttribute(ExampleSet exampleSet)

containsValueType

public static boolean containsValueType(ExampleSet exampleSet,
                                        int valueType)

replaceValue

public static void replaceValue(Attribute attribute,
                                java.lang.String oldValue,
                                java.lang.String newValue)
Replaces the given real value by the new one. Please note that this method will only work for nominal attributes.


replaceValue

public static void replaceValue(ExampleSet exampleSet,
                                Attribute attribute,
                                java.lang.String oldValue,
                                java.lang.String newValue)
Replaces the given value by the new one. This method will only work for nominal attributes.


replaceValue

public static void replaceValue(ExampleSet exampleSet,
                                Attribute attribute,
                                double oldValue,
                                double newValue)
Replaces the given real value by the new one. Please note that this method will only properly work for numerical attributes since for nominal attributes no remapping is performed. Please note also that this method performs a data scan.


compatible

public static boolean compatible(Attribute first,
                                 Attribute second)
Returns true if value and block types of the first attribute are subtypes of value and block type of the second.


getAverageWeight

public static double getAverageWeight(AttributeWeightedExampleSet exampleSet)

getProbabilitiesFromWeights

public static double[] getProbabilitiesFromWeights(Attribute[] attributes,
                                                   AttributeWeightedExampleSet exampleSet)

getInverseProbabilitiesFromWeights

public static double[] getInverseProbabilitiesFromWeights(Attribute[] attributes,
                                                          AttributeWeightedExampleSet exampleSet)

getProbabilitiesFromWeights

public static double[] getProbabilitiesFromWeights(Attribute[] attributes,
                                                   AttributeWeightedExampleSet exampleSet,
                                                   boolean inverse)
Calculates probabilities for attribute selection purposes based on the given weight. Attributes whose weight is not defined in the weight vector get a probability corresponding to the average weight. Inverse probabilities can be calculated for cases where attributes with a high weight should be selected with small probability.


selectAttribute

public static Attribute selectAttribute(Attribute[] attributes,
                                        double[] probs,
                                        java.util.Random random)

isDefault

public static boolean isDefault(double defaultValue,
                                double value)

onlyNonMissingValues

public static void onlyNonMissingValues(ExampleSet exampleSet,
                                        java.lang.String task)
                                 throws OperatorException
The data set is not allowed to contain missing values.

Throws:
OperatorException

onlyNumericalAttributes

public static void onlyNumericalAttributes(ExampleSet es,
                                           java.lang.String task)
                                    throws OperatorException
The attributes all have to be numerical.

Parameters:
es - the example set
Throws:
OperatorException

onlyNominalAttributes

public static void onlyNominalAttributes(ExampleSet es,
                                         java.lang.String task)
                                  throws OperatorException
The attributes all have to be nominal or binary.

Parameters:
es - the example set
Throws:
OperatorException

isLabelled

public static void isLabelled(ExampleSet es)
                       throws OperatorException
The example set has to contain labels.

Parameters:
es - the example set
Throws:
OperatorException

isIdTagged

public static void isIdTagged(ExampleSet es)
                       throws OperatorException
The example set has to be tagged with ids.

Parameters:
es - the example set
Throws:
OperatorException

checkAndCreateIds

public static void checkAndCreateIds(ExampleSet es)
                              throws OperatorException
The example set has to have ids. If no id attribute is available, it will be automatically created with help of the IDTagging operator.

Parameters:
es - the example set
Throws:
OperatorException

hasNominalLabels

public static void hasNominalLabels(ExampleSet es)
                             throws OperatorException
The example set has to have nominal labels.

Parameters:
es - the example set
Throws:
OperatorException

isNonEmpty

public static void isNonEmpty(ExampleSet es)
                       throws OperatorException
The example set has to contain at least one example.

Parameters:
es - the example set
Throws:
OperatorException

getLinearSubsetCopy

public static ExampleSet getLinearSubsetCopy(ExampleSet exampleSet,
                                             int size,
                                             int offset)
Returns a new example set based on a fresh memory example table sampled from the given set.


getShuffledSubsetCopy

public static ExampleSet getShuffledSubsetCopy(ExampleSet exampleSet,
                                               int size,
                                               RandomGenerator randomGenerator)
Returns a new example set based on a fresh memory example table sampled from the given set.



Copyright © 2001-2009 by Rapid-I