Package com.namsor.oss.classify.bayes
Class AbstractNaiveBayesClassifierLevelDBImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierLevelDBImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
- Direct Known Subclasses:
NaiveBayesClassifierLevelDBImpl
,NaiveBayesClassifierLevelDBLaplacedImpl
public abstract class AbstractNaiveBayesClassifierLevelDBImpl extends AbstractNaiveBayesClassifierImpl
A persistent Naive Bayes Classifier, based on LevelDB key-value store. Persistence methods : you can switch between using - the JNI Level DB implementation (import static org.fusesource.leveldbjni.JniDBFactory.*;) or - the pure Java port (import static org.iq80.leveldb.impl.Iq80DBFactory.*;)- Author:
- elian
-
-
Field Summary
-
Fields inherited from class com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
orderByProba
-
-
Constructor Summary
Constructors Constructor Description AbstractNaiveBayesClassifierLevelDBImpl(String classifierName, String[] categories, int cacheSizeMb, String rootPathWritable)
Create a persistent Naive Bayes Classifier using LevelDBAbstractNaiveBayesClassifierLevelDBImpl(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 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()
org.iq80.leveldb.DB
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
-
AbstractNaiveBayesClassifierLevelDBImpl
public AbstractNaiveBayesClassifierLevelDBImpl(String classifierName, String[] categories, int cacheSizeMb, String rootPathWritable) throws PersistentClassifierException
Create a persistent Naive Bayes Classifier using LevelDB- Parameters:
classifierName
- The classifier namecategories
- The immutable classification categoriescacheSizeMb
- LevelDB cache size (ex 100mb)rootPathWritable
- The writable directory for LevelDB storage- Throws:
PersistentClassifierException
- The persistence error and cause
-
AbstractNaiveBayesClassifierLevelDBImpl
public AbstractNaiveBayesClassifierLevelDBImpl(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
-
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
public org.iq80.leveldb.DB 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
-
-