CategoryType - The output category type for the categorizer. Must implement equals and
hash code.DistributionType - The type of the distributions used to compute the conditionals for each
dimension.public class VectorNaiveBayesCategorizer<CategoryType,DistributionType extends UnivariateProbabilityDensityFunction> extends AbstractCloneableSerializable implements Categorizer<Vectorizable,CategoryType>, VectorInputEvaluator<Vectorizable,CategoryType>, DiscriminantCategorizer<Vectorizable,CategoryType,java.lang.Double>
| Modifier and Type | Class and Description |
|---|---|
static class |
VectorNaiveBayesCategorizer.BatchGaussianLearner<CategoryType>
A supervised batch distributionLearner for a vector Naive Bayes categorizer that fits
a Gaussian.
|
static class |
VectorNaiveBayesCategorizer.Learner<CategoryType,DistributionType extends UnivariateProbabilityDensityFunction>
A supervised batch distributionLearner for a vector Naive Bayes categorizer.
|
static class |
VectorNaiveBayesCategorizer.OnlineLearner<CategoryType,DistributionType extends UnivariateProbabilityDensityFunction>
An online (incremental) distributionLearner for the Naive Bayes
categorizer that uses an incremental distribution learner for the
distribution representing each dimension for each category.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<CategoryType,java.util.List<DistributionType>> |
conditionals
The mapping of category to the conditional distribution for the category
with one probability density function for each dimension.
|
protected DataDistribution<CategoryType> |
priors
The prior distribution for the categorizer.
|
| Constructor and Description |
|---|
VectorNaiveBayesCategorizer()
Creates a new
VectorNaiveBayesCategorizer with an empty prior
and conditionals. |
VectorNaiveBayesCategorizer(DataDistribution<CategoryType> priors,
java.util.Map<CategoryType,java.util.List<DistributionType>> conditionals)
Creates a new
VectorNaiveBayesCategorizer with the given prior
and conditionals. |
| Modifier and Type | Method and Description |
|---|---|
VectorNaiveBayesCategorizer<CategoryType,DistributionType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
computeLogPosterior(Vector input,
CategoryType category)
Computes the log-posterior probability that the input belongs to the
given category.
|
double |
computePosterior(Vector input,
CategoryType category)
Computes the posterior probability that the input belongs to the
given category.
|
CategoryType |
evaluate(Vectorizable input)
Evaluates the function on the given input and returns the output.
|
DefaultWeightedValueDiscriminant<CategoryType> |
evaluateWithDiscriminant(Vectorizable input)
Evaluate the categorizer on the given input to produce the expected
category plus a discriminant for later producing an ordering of how well
items fit into that category.
|
java.util.Set<CategoryType> |
getCategories()
Gets the list of possible categories that the categorizer can produce.
|
java.util.Map<CategoryType,java.util.List<DistributionType>> |
getConditionals()
Gets the conditional distributions, which is a mapping of category to
the list of probability density functions, one for each dimension of the
vector.
|
int |
getInputDimensionality()
Gets the expected dimensionality of the input vector to the evaluator,
if it is known.
|
DataDistribution<CategoryType> |
getPriors()
Gets the prior distribution over the categories.
|
void |
setConditionals(java.util.Map<CategoryType,java.util.List<DistributionType>> conditionals)
Sets the conditional distributions, which is a mapping of category to
the list of probability density functions, one for each dimension of the
vector.
|
void |
setPriors(DataDistribution<CategoryType> priors)
Sets the prior distribution over the categories.
|
protected DataDistribution<CategoryType> priors
protected java.util.Map<CategoryType,java.util.List<DistributionType extends UnivariateProbabilityDensityFunction>> conditionals
public VectorNaiveBayesCategorizer()
VectorNaiveBayesCategorizer with an empty prior
and conditionals.public VectorNaiveBayesCategorizer(DataDistribution<CategoryType> priors, java.util.Map<CategoryType,java.util.List<DistributionType>> conditionals)
VectorNaiveBayesCategorizer with the given prior
and conditionals.priors - The prior distribution.conditionals - The conditional distribution.public VectorNaiveBayesCategorizer<CategoryType,DistributionType> clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic CategoryType evaluate(Vectorizable input)
Evaluatorevaluate in interface Evaluator<Vectorizable,CategoryType>input - The input to evaluate.public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(Vectorizable input)
DiscriminantCategorizerevaluateWithDiscriminant in interface DiscriminantCategorizer<Vectorizable,CategoryType,java.lang.Double>input - The input value to categorize with a discriminatepublic double computePosterior(Vector input, CategoryType category)
input - The input vector.category - The category to compute the posterior for.public double computeLogPosterior(Vector input, CategoryType category)
input - The input vector.category - The category to compute the posterior for.public java.util.Set<CategoryType> getCategories()
CategorizergetCategories in interface Categorizer<Vectorizable,CategoryType>public int getInputDimensionality()
VectorInputEvaluatorgetInputDimensionality in interface VectorInputEvaluator<Vectorizable,CategoryType>public DataDistribution<CategoryType> getPriors()
public void setPriors(DataDistribution<CategoryType> priors)
priors - The prior distribution over the categories.public java.util.Map<CategoryType,java.util.List<DistributionType>> getConditionals()
public void setConditionals(java.util.Map<CategoryType,java.util.List<DistributionType>> conditionals)
conditionals - The conditional distributions for each category.