org.knime.base.node.mine.bayes.naivebayes.datamodel
Class NumericalAttributeModel

java.lang.Object
  extended by org.knime.base.node.mine.bayes.naivebayes.datamodel.AttributeModel
      extended by org.knime.base.node.mine.bayes.naivebayes.datamodel.NumericalAttributeModel
All Implemented Interfaces:
Comparable<AttributeModel>

 class NumericalAttributeModel
extends AttributeModel

This AttributeModel implementation calculates the probability for numerical attributes by assuming a Gaussian distribution of the data.

Author:
Tobias Koetter, University of Konstanz

Field Summary
(package private) static String MODEL_TYPE
          The unique type of this model used for saving/loading.
(package private) static double PROB_FACT_DEN
          Pre calculated factor used to calculate the standard deviation.
 
Fields inherited from class org.knime.base.node.mine.bayes.naivebayes.datamodel.AttributeModel
MODEL_CONTAINS_NO_CLASS_VALUES, MODEL_CONTAINS_NO_RECORDS
 
Constructor Summary
NumericalAttributeModel(String attributeName, boolean skipMissingVals)
          Constructor for class NumericalRowValue.
NumericalAttributeModel(String attributeName, boolean skipMissingVals, int noOfMissingVals, Config config)
          Constructor for class NumericalAttributeModel.
 
Method Summary
(package private)  void addValueInternal(String classValue, DataCell attrValue)
          Adds the given value to the concrete implementation.
(package private)  Collection<String> getClassValues()
          
(package private)  Class<? extends DataValue> getCompatibleType()
          
(package private)  String getHTMLView(int totalNoOfRecs)
          
(package private)  String getHTMLViewHeadLine()
          
(package private)  Integer getNoOfRecs4ClassValue(String classValue)
          
(package private)  double getProbabilityInternal(String classValue, DataCell attributeValue, double laplaceCorrector)
          This should also handle missing values.
(package private)  String getType()
          
(package private)  void saveModelInternal(Config config)
          
 String toString()
          
(package private)  void validate()
          Called after all training rows where added to validate the model.
 
Methods inherited from class org.knime.base.node.mine.bayes.naivebayes.datamodel.AttributeModel
addValue, compareTo, createHTMLTable, createTableHeader, getAttributeName, getInvalidCause, getMissingValueHeader, getNoOfMissingVals, getProbability, loadModel, saveModel, setInvalidCause, sortCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROB_FACT_DEN

static final double PROB_FACT_DEN
Pre calculated factor used to calculate the standard deviation.


MODEL_TYPE

static final String MODEL_TYPE
The unique type of this model used for saving/loading.

See Also:
Constant Field Values
Constructor Detail

NumericalAttributeModel

NumericalAttributeModel(String attributeName,
                        boolean skipMissingVals)
Constructor for class NumericalRowValue.

Parameters:
attributeName - the row caption
skipMissingVals - set to true if the missing values should be skipped during learning and prediction

NumericalAttributeModel

NumericalAttributeModel(String attributeName,
                        boolean skipMissingVals,
                        int noOfMissingVals,
                        Config config)
                  throws InvalidSettingsException
Constructor for class NumericalAttributeModel.

Parameters:
attributeName - the name of the attribute
skipMissingVals - set to true if the missing values should be skipped during learning and prediction
noOfMissingVals - the number of missing values
config - the Config object to read from
Throws:
InvalidSettingsException - if the settings are invalid
Method Detail

saveModelInternal

void saveModelInternal(Config config)

Specified by:
saveModelInternal in class AttributeModel
Parameters:
config - the config object to save to

addValueInternal

void addValueInternal(String classValue,
                      DataCell attrValue)
Adds the given value to the concrete implementation. Should handle missing values as well.

Specified by:
addValueInternal in class AttributeModel
Parameters:
classValue - the class value
attrValue - the attribute value. Could be a missing value.

validate

void validate()
        throws InvalidSettingsException
Called after all training rows where added to validate the model.

Specified by:
validate in class AttributeModel
Throws:
InvalidSettingsException - if the model isn't valid

getCompatibleType

Class<? extends DataValue> getCompatibleType()

Specified by:
getCompatibleType in class AttributeModel
Returns:
the DataValue class to check if the rows are compatible

getClassValues

Collection<String> getClassValues()

Specified by:
getClassValues in class AttributeModel
Returns:
all class values

getNoOfRecs4ClassValue

Integer getNoOfRecs4ClassValue(String classValue)

Specified by:
getNoOfRecs4ClassValue in class AttributeModel
Parameters:
classValue - the class value we want the number of records for
Returns:
the number of records with the given class value or null if only missing values where in this row for the given class value or the class value wasn't found at all

getProbabilityInternal

double getProbabilityInternal(String classValue,
                              DataCell attributeValue,
                              double laplaceCorrector)
This should also handle missing values.

Specified by:
getProbabilityInternal in class AttributeModel
Parameters:
classValue - the class value to calculate the probability for
attributeValue - the attribute value to calculate the probability for. Could be a missing value.
laplaceCorrector - the Laplace corrector to use. A value greater 0 overcomes zero counts.
Returns:
the calculated probability

getHTMLViewHeadLine

String getHTMLViewHeadLine()

Specified by:
getHTMLViewHeadLine in class AttributeModel
Returns:
the headline of this model to use in the HTML view

getType

String getType()

Specified by:
getType in class AttributeModel
Returns:
the unique type of the model

getHTMLView

String getHTMLView(int totalNoOfRecs)

Specified by:
getHTMLView in class AttributeModel
Parameters:
totalNoOfRecs - the total number of records in the training data
Returns:
the HTML view of this attribute model

toString

public String toString()

Overrides:
toString in class Object


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.