Package com.namsor.oss.classify.bayes
Class NaiveBayesClassifierRocksDBLaplacedImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierRocksDBImpl
-
- com.namsor.oss.classify.bayes.NaiveBayesClassifierRocksDBLaplacedImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
public class NaiveBayesClassifierRocksDBLaplacedImpl extends AbstractNaiveBayesClassifierRocksDBImpl implements INaiveBayesClassifier
Naive Bayes Classifier with Laplace smoothing and implementation with RocksDB 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 NaiveBayesClassifierRocksDBLaplacedImpl(String classifierName, String[] categories, String rootPathWritable)
Create a Naive Bayes Classifier implementation with RocksDB as key/value store and defaults for Laplace smoothing (ALPHA=1 and VARIANT=false)NaiveBayesClassifierRocksDBLaplacedImpl(String classifierName, String[] categories, String rootPathWritable, double alpha, boolean variant)
Create a Naive Bayes Classifier implementation with RocksDB as key/value store.
-
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.AbstractNaiveBayesClassifierRocksDBImpl
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
-
NaiveBayesClassifierRocksDBLaplacedImpl
public NaiveBayesClassifierRocksDBLaplacedImpl(String classifierName, String[] categories, String rootPathWritable, double alpha, boolean variant) throws PersistentClassifierException
Create a Naive Bayes Classifier implementation with RocksDB as key/value store.- Parameters:
classifierName
- The classifier namecategories
- The classification categoriesrootPathWritable
- A writable path for RocksDBalpha
- The Laplace alpha, typically 1.0variant
- The Laplace variant- Throws:
PersistentClassifierException
- The persistence error and cause
-
NaiveBayesClassifierRocksDBLaplacedImpl
public NaiveBayesClassifierRocksDBLaplacedImpl(String classifierName, String[] categories, String rootPathWritable) throws PersistentClassifierException
Create a Naive Bayes Classifier implementation with RocksDB as key/value store and defaults for Laplace smoothing (ALPHA=1 and VARIANT=false)- Parameters:
classifierName
- The classifier namecategories
- The classification categoriesrootPathWritable
- A writable path for RocksDB- 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
-
-