Package com.namsor.oss.classify.bayes
Class NaiveBayesClassifierMapImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierMapImpl
-
- com.namsor.oss.classify.bayes.NaiveBayesClassifierMapImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
public class NaiveBayesClassifierMapImpl extends AbstractNaiveBayesClassifierMapImpl implements INaiveBayesClassifier
A simple, scalable Naive Bayes Classifier, based on a key-value store (in memory using ConcurrentHashMap, or disk-based using org.mapdb.HTreeMap)- Author:
- elian
-
-
Field Summary
-
Fields inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
orderByProba
-
-
Constructor Summary
Constructors Constructor Description NaiveBayesClassifierMapImpl(String classifierName, String[] categories)Create in-memory classifier using ConcurrentHashMapNaiveBayesClassifierMapImpl(String classifierName, String[] categories, String rootPathWritable)Create persistent classifier using org.mapdb.HTreeMap
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IClassificationclassify(Map<String,String> features, boolean explainData)Predict most probable class, optionally returning the data needed for future explanation.voidlearn(String category, Map<String,String> features, long weight)Learn from features-
Methods inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierMapImpl
dbClose, dbCloseAndDestroy, dbSize, dumpDb, getDb, getRootPathWritable
-
Methods inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
getCategories, getClassifierName, learn, likelihoodsToProbas
-
Methods inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
pathCategory, pathCategoryFeatureKey, pathCategoryFeatureKeyValue, pathFeatureKey, pathFeatureKeyCountValueTypes, pathFeatureKeyValue, pathGlobal, pathGlobalCountCategories
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.namsor.oss.classify.bayes.INaiveBayesClassifier
dbClose, dbCloseAndDestroy, dbSize, dumpDb, getCategories, learn
-
-
-
-
Constructor Detail
-
NaiveBayesClassifierMapImpl
public NaiveBayesClassifierMapImpl(String classifierName, String[] categories)
Create in-memory classifier using ConcurrentHashMap- Parameters:
classifierName- The classifier namecategories- The classification categories
-
NaiveBayesClassifierMapImpl
public NaiveBayesClassifierMapImpl(String classifierName, String[] categories, String rootPathWritable)
Create persistent classifier using org.mapdb.HTreeMap- Parameters:
classifierName- The classifier namecategories- The classification categoriesrootPathWritable- A writable directory for org.mapdb.HTreeMap storage
-
-
Method Detail
-
learn
public void learn(String category, Map<String,String> features, long weight) throws ClassifyException
Description copied from interface:INaiveBayesClassifierLearn from features- Specified by:
learnin interfaceINaiveBayesClassifier- Parameters:
category- The categoryfeatures- The featuresweight- The weight- Throws:
ClassifyException- The classification error and cause
-
classify
public IClassification classify(Map<String,String> features, boolean explainData) throws ClassifyException
Description copied from interface:INaiveBayesClassifierPredict most probable class, optionally returning the data needed for future explanation.- Specified by:
classifyin interfaceINaiveBayesClassifier- Parameters:
features- The featuresexplainData- If should return the data needed for future explanation- Returns:
- The most likely classes with probability and (optionally) the explanation
- Throws:
ClassifyException- The classification error and cause
-
-