|
||||||||||
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.NaiveBayesModel
public class NaiveBayesModel
This class represents the learned Naive Bayes model. This basic model
holds for each attribute an AttributeModel
. Which provides the
probability information for each class value.
Field Summary | |
---|---|
static NumberFormat |
HTML_VALUE_FORMATER
The NumberFormater to use in the html views. |
Constructor Summary | |
---|---|
NaiveBayesModel(BufferedDataTable data,
String classColName,
ExecutionContext exec,
int maxNoOfNominalVals,
boolean skipMissingVals)
Constructor which iterates through the DataTable to
calculate the needed Bayes variables. |
|
NaiveBayesModel(ConfigRO predParams)
Constructor for class NaiveBayesModel. |
Method Summary | |
---|---|
List<String> |
check4MissingCols(DataTableSpec tableSpec)
Checks if the model contains attributes which are not present in the given table specification which could influence the prediction result. |
List<String> |
check4UnknownCols(DataTableSpec tableSpec)
Checks if the given table specification contains columns which are not covered by the learned model. |
boolean |
containsSkippedAttributes()
|
AttributeModel |
getAttributeModel(String attributeName)
|
Collection<AttributeModel> |
getAttributeModels()
|
List<String> |
getAttributesWithMissingVals()
|
DataType |
getClassColumnDataType()
|
String |
getClassColumnName()
|
double |
getClassPriorProbability(String classValue)
|
double[] |
getClassProbabilities(String[] attributeNames,
DataRow row,
List<String> classValues,
boolean normalize,
double laplaceCorrector)
|
String |
getHTMLView()
|
String |
getMostLikelyClass(String[] attrNames,
DataRow row,
double laplaceCorrector)
Returns the name of the class with the highest probability for the given row. |
int |
getNoOfRecs()
|
List<AttributeModel> |
getSkippedAttributes()
|
String |
getSkippedAttributesString(int max2Show)
|
List<String> |
getSortedClassValues()
|
String |
getSummary()
|
void |
savePredictorParams(ConfigWO predParams)
|
String |
toString()
|
void |
updateModel(DataRow row,
DataTableSpec tableSpec,
int classColIdx)
Updates the current NaiveBayesModel with the values from the
given DataRow . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final NumberFormat HTML_VALUE_FORMATER
NumberFormater
to use in the html views.
Constructor Detail |
---|
public NaiveBayesModel(BufferedDataTable data, String classColName, ExecutionContext exec, int maxNoOfNominalVals, boolean skipMissingVals) throws CanceledExecutionException, InvalidSettingsException
DataTable
to
calculate the needed Bayes variables.
data
- The BufferedDataTable
with the dataclassColName
- The name of the column with the classexec
- the ExecutionContext
to provide progress
information and check for cancelmaxNoOfNominalVals
- the maximum number of supported unique
nominal attribute valuesskipMissingVals
- set to true
if the missing values
should be skipped during learning and prediction
CanceledExecutionException
- if the user presses the cancel
button during model creation
InvalidSettingsException
- if the input data contains no rowspublic NaiveBayesModel(ConfigRO predParams) throws InvalidSettingsException
predParams
- the ModelContentRO
to read from
InvalidSettingsException
- if a mandatory key is not availableMethod Detail |
---|
public void updateModel(DataRow row, DataTableSpec tableSpec, int classColIdx) throws InvalidSettingsException
NaiveBayesModel
with the values from the
given DataRow
.
row
- DataRow with values for updatetableSpec
- underlying DataTableSpecclassColIdx
- the index of the class column
InvalidSettingsException
- if missing values occur in class column
or an attribute has too many values.public void savePredictorParams(ConfigWO predParams)
predParams
- to save the modelpublic boolean containsSkippedAttributes()
true
if the model contains skipped attributespublic List<AttributeModel> getSkippedAttributes()
public String getSkippedAttributesString(int max2Show)
max2Show
- the maximum number of missing attributes to display
public List<String> getSortedClassValues()
public double getClassPriorProbability(String classValue)
classValue
- the value of the class we want the probability for
public double[] getClassProbabilities(String[] attributeNames, DataRow row, List<String> classValues, boolean normalize, double laplaceCorrector)
attributeNames
- the name of the attributes we want the normalized
probability values forrow
- the row with the values in the same order like the
attribute namesclassValues
- the class values to calculate the probability fornormalize
- set to true
if the probability values
should be normalizedlaplaceCorrector
- the Laplace corrector to use. A value greater 0
tolerates zero counts (i.e. does not produce 0 probabilities)
public int getNoOfRecs()
public String getClassColumnName()
public DataType getClassColumnDataType()
DataType
of the column with the class attribute.public String getSummary()
public String getHTMLView()
public List<String> getAttributesWithMissingVals()
public AttributeModel getAttributeModel(String attributeName)
attributeName
- the name of the attribute
null
if the attribute is not knownpublic Collection<AttributeModel> getAttributeModels()
Collection
with all
AttributeModel
objectspublic String getMostLikelyClass(String[] attrNames, DataRow row, double laplaceCorrector)
attrNames
- the attribute names in the same order
they appear in the given data rowrow
- the row with the attributes in the same order like in the
training data tablelaplaceCorrector
- the Laplace corrector to use. A value greater 0
overcomes zero counts
public String toString()
toString
in class Object
public List<String> check4UnknownCols(DataTableSpec tableSpec)
tableSpec
- the DataTableSpec
to check for unknown
columns
List
public List<String> check4MissingCols(DataTableSpec tableSpec)
tableSpec
- the DataTableSpec
to check for missing
columns
List
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |