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

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

 class ClassAttributeModel
extends AttributeModel

This AttributeModel implementation holds the class attribute information like the number of rows per class value.

Author:
Tobias Koetter, University of Konstanz

Field Summary
(package private) static String MODEL_TYPE
          The unique type of this model used for saving/loading.
 
Fields inherited from class org.knime.base.node.mine.bayes.naivebayes.datamodel.AttributeModel
MODEL_CONTAINS_NO_CLASS_VALUES, MODEL_CONTAINS_NO_RECORDS
 
Constructor Summary
ClassAttributeModel(String rowCaption, boolean skipMissingVals, int maxNoOfClassVals)
          Constructor for class ClassRowValue.
ClassAttributeModel(String attributeName, int noOfMissingVals, boolean skipMissingVals, Config config)
          Constructor for class ClassModel.
 
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

MODEL_TYPE

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

See Also:
Constant Field Values
Constructor Detail

ClassAttributeModel

ClassAttributeModel(String rowCaption,
                    boolean skipMissingVals,
                    int maxNoOfClassVals)
Constructor for class ClassRowValue.

Parameters:
rowCaption - the row caption
skipMissingVals - set to true if the missing values should be skipped during learning and prediction
maxNoOfClassVals - the maximum supported number of class values

ClassAttributeModel

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

Parameters:
attributeName - the name of the attribute
noOfMissingVals - the number of missing values
skipMissingVals - set to true if the missing values should be skipped during learning and prediction
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)
                throws TooManyValuesException
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.
Throws:
TooManyValuesException - if the column contains more unique values than supported by this attribute model

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

getType

String getType()

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

getHTMLViewHeadLine

String getHTMLViewHeadLine()

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

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.