com.rapidminer.operator.learner
Class PredictionModel

java.lang.Object
  extended by com.rapidminer.operator.AbstractIOObject
      extended by com.rapidminer.operator.ResultObjectAdapter
          extended by com.rapidminer.operator.AbstractModel
              extended by com.rapidminer.operator.learner.PredictionModel
All Implemented Interfaces:
IOObject, Model, ResultObject, Readable, Reportable, LoggingHandler, java.io.Serializable
Direct Known Subclasses:
AdaBoostModel, AdditiveRegressionModel, AttributeBasedVotingModel, AttributeDefaultModel, BaggingModel, BayBoostModel, Binary2MultiClassModel, DefaultModel, FastMarginModel, GSSModel, HierarchicalModel, HierarchicalMultiClassModel, HyperModel, ImprovedNeuralNetModel, KernelModel, LinearMySVMModel, LinearRegressionModel, LocalPolynomialRegressionModel, MetaCostModel, MultiModelByRegression, NeuralNetModel, PlattScalingModel, RelativeRegressionModel, SDEnsemble, SeeminglyUnrelatedRegressionModel, SimpleBinaryPredictionModel, SimpleNeuralNetModel, SimplePredictionModel, StackingModel, ThresholdModel, TransformedRegressionModel, UpdateablePredictionModel, VectorRegressionModel

public abstract class PredictionModel
extends AbstractModel

PredictionModel is the superclass for all objects generated by learners, i.e. it can be used to create a prediction for a given example set.

Author:
Ingo Mierswa
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.rapidminer.operator.AbstractIOObject
AbstractIOObject.InputStreamProvider
 
Constructor Summary
protected PredictionModel(ExampleSet trainingExampleSet)
          Created a new prediction model which was built on the given example set.
 
Method Summary
 ExampleSet apply(ExampleSet exampleSet)
          Applies the model by creating a predicted label attribute and setting the predicted label values.
protected  void checkCompatibility(ExampleSet exampleSet)
          This method is invoked before the model is actually applied.
static void copyPredictedLabel(ExampleSet source, ExampleSet destination)
          Copies the predicted label from the source example set to the destination example set.
static Attribute createPredictedLabel(ExampleSet exampleSet, Attribute label)
          Creates a predicted label for the given example set based on the label attribute defined for this prediction model.
protected  Attribute createPredictionAttributes(ExampleSet exampleSet, Attribute label)
          This method creates prediction attributes like the predicted label and confidences if needed.
 Attribute getLabel()
          Returns the label attribute.
abstract  ExampleSet performPrediction(ExampleSet exampleSet, Attribute predictedLabel)
          Subclasses should iterate through the given example set and set the prediction for each example.
static void removePredictedLabel(ExampleSet exampleSet)
          Helper method in order to reduce memory consumption.
static void removePredictedLabel(ExampleSet exampleSet, boolean removePredictionFromTable, boolean removeConfidencesFromTable)
          Helper method in order to lower memory consumption.
protected  boolean supportsConfidences(Attribute label)
          This method determines if confidence attributes are created depending on the current label.
 java.lang.String toString()
           
 
Methods inherited from class com.rapidminer.operator.AbstractModel
getExtension, getFileDescription, getName, getTrainingHeader, isInTargetEncoding, isUpdatable, setParameter, updateModel
 
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, copy, getLog, getProcessingHistory, getSource, initWriting, read, read, read, read, setLoggingHandler, setSource, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, 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, copy, getAnnotations, getLog, getProcessingHistory, getSource, setLoggingHandler, setSource, write
 

Constructor Detail

PredictionModel

protected PredictionModel(ExampleSet trainingExampleSet)
Created a new prediction model which was built on the given example set. Please note that the given example set is automatically transformed into a HeaderExampleSet which means that no reference to the data itself is kept but only to the header, i.e. to the attribute meta descriptions.

Method Detail

performPrediction

public abstract ExampleSet performPrediction(ExampleSet exampleSet,
                                             Attribute predictedLabel)
                                      throws OperatorException
Subclasses should iterate through the given example set and set the prediction for each example. The given predicted label attribute was already be added to the example set and should be used to set the predicted values.

Throws:
OperatorException

apply

public ExampleSet apply(ExampleSet exampleSet)
                 throws OperatorException
Applies the model by creating a predicted label attribute and setting the predicted label values.

Throws:
OperatorException

getLabel

public Attribute getLabel()
Returns the label attribute.


checkCompatibility

protected void checkCompatibility(ExampleSet exampleSet)
                           throws OperatorException
This method is invoked before the model is actually applied. The default implementation performs some basic compatibility checks and writes warnings if the given example set (for applying the model) does not fit the training example set. Subclasses might override this method and might throw exceptions which will prevent the application of the model.

Throws:
OperatorException

createPredictionAttributes

protected Attribute createPredictionAttributes(ExampleSet exampleSet,
                                               Attribute label)
This method creates prediction attributes like the predicted label and confidences if needed.


supportsConfidences

protected boolean supportsConfidences(Attribute label)
This method determines if confidence attributes are created depending on the current label. Usually this depends only on the fact that the label is nominal, but subclasses might override this to avoid attribute construction for confidences.


createPredictedLabel

public static Attribute createPredictedLabel(ExampleSet exampleSet,
                                             Attribute label)
Creates a predicted label for the given example set based on the label attribute defined for this prediction model. Subclasses which override this method should first invoke super.createPredictedLabel(exampleSet) and should then replace the attribute with a new predicted label attribute via a method call like exampleSet.replaceAttribute(predictedLabel, AttributeFactory.changeValueType(predictedLabel, Ontology.REAL)); . This might be useful in cases where a crisp nominal prediction should be replaced by confidence predictions.


toString

public java.lang.String toString()
Specified by:
toString in interface Readable
Overrides:
toString in class java.lang.Object

removePredictedLabel

public static void removePredictedLabel(ExampleSet exampleSet)
Helper method in order to reduce memory consumption. This method should be invoked after a predicted label and confidence are not longer needed, e.g. after each iteration of a crossvalidation or after a meta learning iteration.


removePredictedLabel

public static void removePredictedLabel(ExampleSet exampleSet,
                                        boolean removePredictionFromTable,
                                        boolean removeConfidencesFromTable)
Helper method in order to lower memory consumption. This method should be invoked after a predicted label and confidence are not longer needed, e.g. after each crossvalidation run or after a meta learning iteration.


copyPredictedLabel

public static void copyPredictedLabel(ExampleSet source,
                                      ExampleSet destination)
Copies the predicted label from the source example set to the destination example set. Does nothing if the source does not contain a predicted label.



Copyright © 2001-2009 by Rapid-I