Package com.namsor.oss.classify.bayes
Class ClassificationImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.ClassificationImpl
-
- All Implemented Interfaces:
IClassification
public class ClassificationImpl extends Object implements IClassification
An immutable classification object- Author:
- elian
-
-
Constructor Summary
Constructors Constructor Description ClassificationImpl(Map<String,String> features, IClassProbability[] classProbabilities, Map<String,Long> explanationData)
ClassificationImpl(Map<String,String> features, IClassProbability[] classProbabilities, Map<String,Long> explanationData, boolean laplaceSmoothed, boolean laplaceSmoothedVariant, double laplaceSmoothingAlpha)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IClassProbability[]
getClassProbabilities()
The ordered classes and probabilities.Map<String,Long>
getExplanationData()
All the data needed to explain the results.Map<String,String>
getFeatures()
The input featuresdouble
getLaplaceSmoothingAlpha()
The alpha value used for Laplace smoothingboolean
isLaplaceSmoothed()
Is Laplace smoothed?boolean
isLaplaceSmoothedVariant()
If Laplace Smoothed With variant, then: likelyhood[i] = 1d * ((categoryCount + alpha) / (globalCount + globalCountCategories * alpha)) * product; otherwise: likelyhood[i] = 1d * categoryCount / globalCount * product;
-
-
-
Method Detail
-
getClassProbabilities
public IClassProbability[] getClassProbabilities()
Description copied from interface:IClassification
The ordered classes and probabilities.- Specified by:
getClassProbabilities
in interfaceIClassification
- Returns:
- the classProbabilities
-
getExplanationData
public Map<String,Long> getExplanationData()
Description copied from interface:IClassification
All the data needed to explain the results.- Specified by:
getExplanationData
in interfaceIClassification
- Returns:
- the explanation
-
isLaplaceSmoothed
public boolean isLaplaceSmoothed()
Description copied from interface:IClassification
Is Laplace smoothed?- Specified by:
isLaplaceSmoothed
in interfaceIClassification
- Returns:
- the laplaceSmoothed
-
isLaplaceSmoothedVariant
public boolean isLaplaceSmoothedVariant()
Description copied from interface:IClassification
If Laplace Smoothed With variant, then: likelyhood[i] = 1d * ((categoryCount + alpha) / (globalCount + globalCountCategories * alpha)) * product; otherwise: likelyhood[i] = 1d * categoryCount / globalCount * product;- Specified by:
isLaplaceSmoothedVariant
in interfaceIClassification
- Returns:
- the laplaceSmoothedVariant
-
getFeatures
public Map<String,String> getFeatures()
Description copied from interface:IClassification
The input features- Specified by:
getFeatures
in interfaceIClassification
- Returns:
- the features
-
getLaplaceSmoothingAlpha
public double getLaplaceSmoothingAlpha()
Description copied from interface:IClassification
The alpha value used for Laplace smoothing- Specified by:
getLaplaceSmoothingAlpha
in interfaceIClassification
- Returns:
- the laplaceSmoothingAlpha
-
-