com.rapidminer.operator.learner.bayes
Class KernelDistributionModel

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
                  extended by com.rapidminer.operator.learner.bayes.DistributionModel
                      extended by com.rapidminer.operator.learner.bayes.KernelDistributionModel
All Implemented Interfaces:
IOObject, Model, ResultObject, Saveable, Readable, Renderable, Reportable, LoggingHandler, java.io.Serializable

public class KernelDistributionModel
extends DistributionModel
implements Renderable

KernelDistributionModel is a model for learners which estimate distributions of attribute values from example sets like NaiveBayes. Predictions are calculated as product of the conditional probabilities for all attributes times the class probability. The basic learning concept is to simply count occurances of classes and attribute values. This means no probabilities are calculated during the learning step. This is only done before output. Optionally, this calculation can apply a Laplace correction which means in particular that zero probabilities are avoided which would hide information in distributions of other attributes.

Author:
Tobias Malbrecht
See Also:
Serialized Form

Constructor Summary
KernelDistributionModel(ExampleSet exampleSet, boolean laplaceCorrectionEnabled, int estimationMode, int bandwidthSelectionMode, double bandwidth, int numberOfKernels, int gridSize)
           
 
Method Summary
 void finishRendering()
          Will be invoked directly after rendering and gives the object the chance to perform some clean-up.
 java.lang.String[] getAttributeNames()
           
 java.util.Collection<java.lang.Integer> getClassIndices()
           
 java.lang.String getClassName(int index)
           
 Distribution getDistribution(int classIndex, int attributeIndex)
           
 boolean getLaplaceCorrectionEnabled()
           
 double getLowerBound(int attributeIndex)
           
 int getNumberOfAttributes()
           
 int getNumberOfClasses()
           
 int getRenderHeight(int preferredHeight)
          This method return the pixel height the rendering needs
 int getRenderWidth(int preferredWidth)
          This method returns the pixel width the rendering needs
 double getUpperBound(int attributeIndex)
           
 java.awt.Component getVisualizationComponent(IOContainer container)
          Returns a editor pane that displays the ResultObjectAdapter.toResultString() result encoded as html.
 boolean isDiscrete(int attributeIndex)
           
 boolean isUpdatable()
          This default implementation returns false.
 ExampleSet performPrediction(ExampleSet exampleSet, Attribute predictedLabel)
          Perform predictions based on the distribution properties.
 void prepareRendering()
          Will be invoked before rendering and even before render width and height retrieval.
 void render(java.awt.Graphics graphics, int width, int height)
          This method paints the visual representation onto the given graphics
 void setLaplaceCorrectionEnabled(boolean laplaceCorrectionEnabled)
           
 java.lang.String toString()
           
 void updateModel(ExampleSet exampleSet)
          Updates the model by counting the occurances of classes and attribute values in combination with the class values.
 
Methods inherited from class com.rapidminer.operator.learner.PredictionModel
apply, checkCompatibility, copyPredictedLabel, createPredictedLabel, getLabel, removePredictedLabel, removePredictedLabel
 
Methods inherited from class com.rapidminer.operator.AbstractModel
getExtension, getFileDescription, getName, getResultIcon, getTrainingHeader, setParameter
 
Methods inherited from class com.rapidminer.operator.ResultObjectAdapter
addAction, getActions, isSavable, log, logError, logNote, logWarning, save, toHTML, toResultString
 
Methods inherited from class com.rapidminer.operator.AbstractIOObject
copy, getLog, getSource, initWriting, 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, toResultString
 
Methods inherited from interface com.rapidminer.operator.IOObject
copy, getLog, getSource, setLoggingHandler, setSource, write
 
Methods inherited from interface com.rapidminer.operator.Saveable
isSavable, save
 

Constructor Detail

KernelDistributionModel

public KernelDistributionModel(ExampleSet exampleSet,
                               boolean laplaceCorrectionEnabled,
                               int estimationMode,
                               int bandwidthSelectionMode,
                               double bandwidth,
                               int numberOfKernels,
                               int gridSize)
Method Detail

getAttributeNames

public java.lang.String[] getAttributeNames()
Specified by:
getAttributeNames in class DistributionModel

getNumberOfAttributes

public int getNumberOfAttributes()
Specified by:
getNumberOfAttributes in class DistributionModel

updateModel

public void updateModel(ExampleSet exampleSet)
Updates the model by counting the occurances of classes and attribute values in combination with the class values. ATTENTION: only updates the weight counters, distribution properties are not updated, call updateDistributionProperties() to accomplish this task

Specified by:
updateModel in interface Model
Overrides:
updateModel in class AbstractModel

performPrediction

public ExampleSet performPrediction(ExampleSet exampleSet,
                                    Attribute predictedLabel)
Perform predictions based on the distribution properties.

Specified by:
performPrediction in class DistributionModel

isUpdatable

public boolean isUpdatable()
Description copied from class: AbstractModel
This default implementation returns false. Note that subclasses overriding this method should also override the method AbstractModel.updateModel(ExampleSet).

Specified by:
isUpdatable in interface Model
Overrides:
isUpdatable in class AbstractModel

setLaplaceCorrectionEnabled

public void setLaplaceCorrectionEnabled(boolean laplaceCorrectionEnabled)

getLaplaceCorrectionEnabled

public boolean getLaplaceCorrectionEnabled()

getLowerBound

public double getLowerBound(int attributeIndex)
Specified by:
getLowerBound in class DistributionModel

getUpperBound

public double getUpperBound(int attributeIndex)
Specified by:
getUpperBound in class DistributionModel

isDiscrete

public boolean isDiscrete(int attributeIndex)
Specified by:
isDiscrete in class DistributionModel

getClassIndices

public java.util.Collection<java.lang.Integer> getClassIndices()
Specified by:
getClassIndices in class DistributionModel

getNumberOfClasses

public int getNumberOfClasses()
Specified by:
getNumberOfClasses in class DistributionModel

getClassName

public java.lang.String getClassName(int index)
Specified by:
getClassName in class DistributionModel

getDistribution

public Distribution getDistribution(int classIndex,
                                    int attributeIndex)
Specified by:
getDistribution in class DistributionModel

getVisualizationComponent

public java.awt.Component getVisualizationComponent(IOContainer container)
Description copied from class: ResultObjectAdapter
Returns a editor pane that displays the ResultObjectAdapter.toResultString() result encoded as html. Please note that the returned pane is already enclosed by a scroll pane. If you overwrite this method you should again ensure that the returned component is scrollable. The given container is totally ignored.

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

prepareRendering

public void prepareRendering()
Description copied from interface: Renderable
Will be invoked before rendering and even before render width and height retrieval.

Specified by:
prepareRendering in interface Renderable

finishRendering

public void finishRendering()
Description copied from interface: Renderable
Will be invoked directly after rendering and gives the object the chance to perform some clean-up.

Specified by:
finishRendering in interface Renderable

getRenderHeight

public int getRenderHeight(int preferredHeight)
Description copied from interface: Renderable
This method return the pixel height the rendering needs

Specified by:
getRenderHeight in interface Renderable
Parameters:
preferredHeight - tells the renderable of the size it should deliver best
Returns:
the pixel height

getRenderWidth

public int getRenderWidth(int preferredWidth)
Description copied from interface: Renderable
This method returns the pixel width the rendering needs

Specified by:
getRenderWidth in interface Renderable
Parameters:
preferredWidth - tells the renderable of the size it should deliver best
Returns:
the pixel width

render

public void render(java.awt.Graphics graphics,
                   int width,
                   int height)
Description copied from interface: Renderable
This method paints the visual representation onto the given graphics

Specified by:
render in interface Renderable
Parameters:
graphics - the graphics to render onto

toString

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


Copyright © 2001-2009 by Rapid-I