Package com.namsor.oss.classify.bayes
Class AbstractNaiveBayesClassifierMapImpl
- java.lang.Object
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierImpl
-
- com.namsor.oss.classify.bayes.AbstractNaiveBayesClassifierMapImpl
-
- All Implemented Interfaces:
INaiveBayesClassifier
- Direct Known Subclasses:
NaiveBayesClassifierMapImpl
,NaiveBayesClassifierMapLaplacedImpl
public abstract class AbstractNaiveBayesClassifierMapImpl extends AbstractNaiveBayesClassifierImpl
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 AbstractNaiveBayesClassifierMapImpl(String classifierName, String[] categories)
Create in-memory classifier using ConcurrentHashMapAbstractNaiveBayesClassifierMapImpl(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 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 Map<String,Long>
getDb()
String
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
classify, learn
-
-
-
-
Constructor Detail
-
AbstractNaiveBayesClassifierMapImpl
public AbstractNaiveBayesClassifierMapImpl(String classifierName, String[] categories)
Create in-memory classifier using ConcurrentHashMap- Parameters:
classifierName
- The classifier namecategories
- The classification categories
-
AbstractNaiveBayesClassifierMapImpl
public AbstractNaiveBayesClassifierMapImpl(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
-
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
-
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
-
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
-
getRootPathWritable
public String getRootPathWritable()
- Returns:
- the rootPathWritable
-
-