Package com.namsor.oss.classify.bayes
Class AbstractNaiveBayesClassifierRocksDBImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierRocksDBImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
- Direct Known Subclasses:
NaiveBayesClassifierRocksDBImpl
,NaiveBayesClassifierRocksDBLaplacedImpl
public abstract class AbstractNaiveBayesClassifierRocksDBImpl extends AbstractNaiveBayesClassifierImpl
A persistent Naive Bayes Classifier, based on RocksDB key-value store.- Author:
- elian
-
-
Field Summary
-
Fields inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
orderByProba
-
-
Constructor Summary
Constructors Constructor Description AbstractNaiveBayesClassifierRocksDBImpl(String classifierName, String[] categories, String rootPathWritable)
Create a persistent Naive Bayes Classifier using RocksDB
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
bytes(String key)
void
dbClose()
Close the classifier (if persistent)void
dbCloseAndDestroy()
Close the classifier (if persistent) and destroy the database.long
dbSize()
Estimate the number of key-values in DBvoid
dumpDb(Writer w)
Dump the current state of the model (can be large)protected void
finalize()
protected org.rocksdb.RocksDB
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
classify, learn
-
-
-
-
Constructor Detail
-
AbstractNaiveBayesClassifierRocksDBImpl
public AbstractNaiveBayesClassifierRocksDBImpl(String classifierName, String[] categories, String rootPathWritable) throws PersistentClassifierException
Create a persistent Naive Bayes Classifier using RocksDB- Parameters:
classifierName
- The classifier namecategories
- The immutable classification categoriesrootPathWritable
- The writable directory for LevelDB storage- Throws:
PersistentClassifierException
- The persistence error and cause
-
-
Method Detail
-
dbSize
public long dbSize() throws PersistentClassifierException
Description copied from interface:INaiveBayesClassifier
Estimate the number of key-values in DB- Returns:
- The estimate number of key values
- Throws:
PersistentClassifierException
- The persistence error and cause
-
dbClose
public void dbClose() throws PersistentClassifierException
Description copied from interface:INaiveBayesClassifier
Close the classifier (if persistent)- Throws:
PersistentClassifierException
- The persistence error and cause
-
dbCloseAndDestroy
public void dbCloseAndDestroy() throws PersistentClassifierException
Description copied from interface:INaiveBayesClassifier
Close the classifier (if persistent) and destroy the database.- Throws:
PersistentClassifierException
- The persistence error and cause
-
finalize
protected void finalize() throws Throwable
-
bytes
protected byte[] bytes(String key)
-
getDb
protected org.rocksdb.RocksDB getDb()
- Returns:
- the db
-
dumpDb
public void dumpDb(Writer w) throws PersistentClassifierException
Description copied from interface:INaiveBayesClassifier
Dump the current state of the model (can be large)- Parameters:
w
- A writer- Throws:
PersistentClassifierException
- The persistence error and cause
-
-