Package com.namsor.oss.classify.bayes
Class NaiveBayesClassifierLevelDBImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierLevelDBImpl
-
- com.namsor.oss.classify.bayes.NaiveBayesClassifierLevelDBImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
public class NaiveBayesClassifierLevelDBImpl extends AbstractNaiveBayesClassifierLevelDBImpl implements INaiveBayesClassifier
Naive Bayes Classifier implementation with LevelDB as key/value store. Learning is Synchronized but classification is not.- Author:
- elian carsenat, NamSor SAS
-
-
Field Summary
-
Fields inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
orderByProba
-
-
Constructor Summary
Constructors Constructor Description NaiveBayesClassifierLevelDBImpl(String classifierName, String[] categories, String rootPathWritable)
Create a persistent Naive Bayes Classifier using LevelDB, with default cache size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IClassification
classify(Map<String,String> features, boolean explainData)
Predict most probable class, optionally returning the data needed for future explanation.void
learn(String category, Map<String,String> features, long weight)
Learn from features-
Methods inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierLevelDBImpl
bytes, dbClose, dbCloseAndDestroy, dbSize, dumpDb, finalize, getDb
-
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, 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
-
NaiveBayesClassifierLevelDBImpl
public NaiveBayesClassifierLevelDBImpl(String classifierName, String[] categories, String rootPathWritable) throws PersistentClassifierException
Create a persistent Naive Bayes Classifier using LevelDB, with default cache size- Parameters:
classifierName
- The classifier namecategories
- The immutable classification categoriesrootPathWritable
- The writable directory for LevelDB storage- Throws:
PersistentClassifierException
- The persistence error and cause
-
-
Method Detail
-
learn
public void learn(String category, Map<String,String> features, long weight) throws ClassifyException
Description copied from interface:INaiveBayesClassifier
Learn from features- Specified by:
learn
in 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:INaiveBayesClassifier
Predict most probable class, optionally returning the data needed for future explanation.- Specified by:
classify
in 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
-
-