ObservationType
- Type of observationsCategoryType
- Type of categories@PublicationReference(author="Wikipedia", title="Maximum a posteriori estimation", type=WebPage, year=2010, url="http://en.wikipedia.org/wiki/Maximum_a_posteriori_estimation") public class MaximumAPosterioriCategorizer<ObservationType,CategoryType> extends AbstractDistribution<ObservationType> implements DiscriminantCategorizer<ObservationType,CategoryType,java.lang.Double>
Modifier and Type | Class and Description |
---|---|
static class |
MaximumAPosterioriCategorizer.Learner<ObservationType,CategoryType>
Learner for the MAP categorizer
|
Constructor and Description |
---|
MaximumAPosterioriCategorizer()
Creates a new instance of MaximumAPosterioriCategorizer
|
Modifier and Type | Method and Description |
---|---|
void |
addCategory(CategoryType category,
double mass,
ProbabilityFunction<ObservationType> conditional)
Adds the given category with the given mass (which is divided by the
masses of all categories to determine the prior probability weight)
and the distribution function
|
MaximumAPosterioriCategorizer<ObservationType,CategoryType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
computePosterior(ObservationType observation,
CategoryType category)
Computes the posterior of the observation given the category.
|
CategoryType |
evaluate(ObservationType input)
Evaluates the function on the given input and returns the output.
|
DefaultWeightedValueDiscriminant<CategoryType> |
evaluateWithDiscriminant(ObservationType 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<? extends CategoryType> |
getCategories()
Gets the list of possible categories that the categorizer can produce.
|
WeightedValue<ProbabilityFunction<ObservationType>> |
getCategory(CategoryType category)
Gets the prior probability weight and conditional distribution for
the given category.
|
ObservationType |
getMean()
Gets the mean category, if it is a number or ring.
|
void |
sampleInto(java.util.Random random,
int numSamples,
java.util.Collection<? super ObservationType> output)
Draws multiple random samples from the distribution and puts the result
into the given collection.
|
sample, sample
public MaximumAPosterioriCategorizer()
public MaximumAPosterioriCategorizer<ObservationType,CategoryType> clone()
AbstractCloneableSerializable
Object
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 CloneableSerializable
clone
in class AbstractCloneableSerializable
public void addCategory(CategoryType category, double mass, ProbabilityFunction<ObservationType> conditional)
category
- Category to addmass
- Mass of the categoryconditional
- Conditional probability function of observations for the categorypublic WeightedValue<ProbabilityFunction<ObservationType>> getCategory(CategoryType category)
category
- Category to considerpublic java.util.Set<? extends CategoryType> getCategories()
Categorizer
getCategories
in interface Categorizer<ObservationType,CategoryType>
public CategoryType evaluate(ObservationType input)
Evaluator
evaluate
in interface Evaluator<ObservationType,CategoryType>
input
- The input to evaluate.public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(ObservationType input)
DiscriminantCategorizer
evaluateWithDiscriminant
in interface DiscriminantCategorizer<ObservationType,CategoryType,java.lang.Double>
input
- The input value to categorize with a discriminatepublic double computePosterior(ObservationType observation, CategoryType category)
observation
- Observation to considercategory
- Category to considerpublic ObservationType getMean()
public void sampleInto(java.util.Random random, int numSamples, java.util.Collection<? super ObservationType> output)
Distribution
sampleInto
in interface Distribution<ObservationType>
random
- Random number generator to use.numSamples
- The number of samples to draw. Cannot be negative.output
- The collection to add the samples into.