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 featuresdoublegetLaplaceSmoothingAlpha()The alpha value used for Laplace smoothingbooleanisLaplaceSmoothed()Is Laplace smoothed?booleanisLaplaceSmoothedVariant()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:IClassificationThe ordered classes and probabilities.- Specified by:
getClassProbabilitiesin interfaceIClassification- Returns:
- the classProbabilities
-
getExplanationData
public Map<String,Long> getExplanationData()
Description copied from interface:IClassificationAll the data needed to explain the results.- Specified by:
getExplanationDatain interfaceIClassification- Returns:
- the explanation
-
isLaplaceSmoothed
public boolean isLaplaceSmoothed()
Description copied from interface:IClassificationIs Laplace smoothed?- Specified by:
isLaplaceSmoothedin interfaceIClassification- Returns:
- the laplaceSmoothed
-
isLaplaceSmoothedVariant
public boolean isLaplaceSmoothedVariant()
Description copied from interface:IClassificationIf Laplace Smoothed With variant, then: likelyhood[i] = 1d * ((categoryCount + alpha) / (globalCount + globalCountCategories * alpha)) * product; otherwise: likelyhood[i] = 1d * categoryCount / globalCount * product;- Specified by:
isLaplaceSmoothedVariantin interfaceIClassification- Returns:
- the laplaceSmoothedVariant
-
getFeatures
public Map<String,String> getFeatures()
Description copied from interface:IClassificationThe input features- Specified by:
getFeaturesin interfaceIClassification- Returns:
- the features
-
getLaplaceSmoothingAlpha
public double getLaplaceSmoothingAlpha()
Description copied from interface:IClassificationThe alpha value used for Laplace smoothing- Specified by:
getLaplaceSmoothingAlphain interfaceIClassification- Returns:
- the laplaceSmoothingAlpha
-
-