|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.base.node.mine.bayes.naivebayes.datamodel.AttributeModel
public abstract class AttributeModel
This abstract class needs to be implemented by all attribute models and provides missing value handling and some common methods.
Field Summary | |
---|---|
(package private) static String |
MODEL_CONTAINS_NO_CLASS_VALUES
Invalid cause if the model contains no class values. |
(package private) static String |
MODEL_CONTAINS_NO_RECORDS
Invalid cause if the model contains no records at all. |
Constructor Summary | |
---|---|
AttributeModel(String attributeName,
int noOfMissingVals,
boolean skipMissingVals)
Constructor for class ClassValue. |
Method Summary | |
---|---|
(package private) void |
addValue(String classValue,
DataCell attrValue)
Adds the given value to this attribute model. |
(package private) abstract void |
addValueInternal(String classValue,
DataCell attrValue)
Adds the given value to the concrete implementation. |
int |
compareTo(AttributeModel o)
|
(package private) static String |
createHTMLTable(String tableHeading,
String keyHeading,
String valueHeading,
int noOfRows,
Map<String,? extends Object> map,
boolean addLineBreak)
|
protected static String |
createTableHeader(String firstHeading,
List<String> headings,
String lastHeading)
|
String |
getAttributeName()
|
(package private) abstract Collection<String> |
getClassValues()
|
(package private) abstract Class<? extends DataValue> |
getCompatibleType()
|
(package private) abstract String |
getHTMLView(int totalNoOfRecs)
|
(package private) abstract String |
getHTMLViewHeadLine()
|
String |
getInvalidCause()
|
(package private) String |
getMissingValueHeader(Collection<String> colNames)
|
(package private) int |
getNoOfMissingVals()
|
(package private) abstract Integer |
getNoOfRecs4ClassValue(String classValue)
|
(package private) Double |
getProbability(String classValue,
DataCell attributeValue,
double laplaceCorrector)
|
(package private) abstract double |
getProbabilityInternal(String classValue,
DataCell attributeValue,
double laplaceCorrector)
This should also handle missing values. |
(package private) abstract String |
getType()
|
(package private) static AttributeModel |
loadModel(Config config)
|
(package private) void |
saveModel(Config config)
|
(package private) abstract void |
saveModelInternal(Config config)
|
(package private) void |
setInvalidCause(String cause)
|
(package private) static List<String> |
sortCollection(Collection<String> vals)
|
(package private) abstract void |
validate()
Called after all training rows where added to validate the model. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final String MODEL_CONTAINS_NO_RECORDS
static final String MODEL_CONTAINS_NO_CLASS_VALUES
Constructor Detail |
---|
AttributeModel(String attributeName, int noOfMissingVals, boolean skipMissingVals)
attributeName
- the name of the attributenoOfMissingVals
- the number of missing valuesskipMissingVals
- set to true
if the missing values
should be skipped during learning and predictionMethod Detail |
---|
static AttributeModel loadModel(Config config) throws InvalidSettingsException
config
- the Config
object to read from
Config
object
InvalidSettingsException
- if the settings are invalidvoid saveModel(Config config)
config
- the Config
object to write toabstract void saveModelInternal(Config config)
config
- the config object to save toabstract String getType()
public String getAttributeName()
abstract Class<? extends DataValue> getCompatibleType()
DataValue
class to check if the rows
are compatiblevoid addValue(String classValue, DataCell attrValue) throws TooManyValuesException
classValue
- the class valueattrValue
- the attribute value. Could be a missing value.
TooManyValuesException
- if the column contains more unique
values than supported by this attribute modelabstract void addValueInternal(String classValue, DataCell attrValue) throws TooManyValuesException
classValue
- the class valueattrValue
- the attribute value. Could be a missing value.
TooManyValuesException
- if the column contains more unique
values than supported by this attribute modelint getNoOfMissingVals()
String getMissingValueHeader(Collection<String> colNames)
colNames
- all column names of the table to check for uniquness
null
if this model
contains no missing attribute valuesabstract Collection<String> getClassValues()
abstract Integer getNoOfRecs4ClassValue(String classValue)
classValue
- the class value we want the number of records for
null
if only missing values where in this row for the
given class value or the class value wasn't found at allDouble getProbability(String classValue, DataCell attributeValue, double laplaceCorrector)
classValue
- the class value to calculate the probability forattributeValue
- 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.
abstract double getProbabilityInternal(String classValue, DataCell attributeValue, double laplaceCorrector)
classValue
- the class value to calculate the probability forattributeValue
- 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.
abstract String getHTMLView(int totalNoOfRecs)
totalNoOfRecs
- the total number of records in the training data
static List<String> sortCollection(Collection<String> vals)
vals
- the Collection
to sort
Collection
in her natural orderabstract void validate() throws InvalidSettingsException
InvalidSettingsException
- if the model isn't validvoid setInvalidCause(String cause)
cause
- the cause why this model is invalidpublic String getInvalidCause()
public int compareTo(AttributeModel o)
compareTo
in interface Comparable<AttributeModel>
abstract String getHTMLViewHeadLine()
static String createHTMLTable(String tableHeading, String keyHeading, String valueHeading, int noOfRows, Map<String,? extends Object> map, boolean addLineBreak)
tableHeading
- the optional table headlinekeyHeading
- the optional headline for the key rowvalueHeading
- the optional headline for the value rownoOfRows
- the number of rows displayed per rowmap
- the map to create the html table foraddLineBreak
- if each sub table should be displayed on a new line
protected static String createTableHeader(String firstHeading, List<String> headings, String lastHeading)
firstHeading
- the optional first headingheadings
- the head lineslastHeading
- the optional last heading
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |