com.ibm.able.beans.bayes
Class AbleNaiveBayes
java.lang.Object
|
+--com.ibm.able.AbleObject
|
+--com.ibm.able.beans.bayes.AbleNaiveBayes
- All Implemented Interfaces:
- AbleBean, AbleDataBufferManager, AbleEventListener, AbleEventListenerManager, AbleEventQueueManager, AbleEventQueueProcessor, AblePropertyChangeManager, AbleSerializable, java.io.Serializable
- public class AbleNaiveBayes
- extends AbleObject
- See Also:
- Serialized Form
Fields inherited from class com.ibm.able.AbleObject |
changed, chgSupport, comment, dataFlowEnabled, defaultName, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace |
Constructor Summary |
AbleNaiveBayes()
construct an AbleNaiveBayes bean |
AbleNaiveBayes(int ncls,
int nftr,
int[] nval,
int m,
double[] cpriors,
double[][][] ppriors)
construct AbleNaiveBayes bean with the explicitly specified parameters
ncls - number of class labels
nftr - number of features
nval - number of values per each feature (assuming nominal - discrete finite-valued - features)
cpriors - prior probability distribution over class labels
m - equivalent sample size
ppriors - prior estimates of the probabilities P(f|C) (used for Bayesian parameter estimation
with equivalent sample size method) |
AbleNaiveBayes(java.lang.String name)
construct an AbleNaiveBayes bean |
Methods inherited from class com.ibm.able.AbleObject |
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, Copyright, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, getTraceLogger, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, process, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, quitAll, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllConnections, removeAllPropertyConnections, removeDestBufferConnection, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeAll, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setInputBuffer, setLogger, setName, setOutputBuffer, setOutputBuffer, setParent, setSleepTime, setState, setTimerEventProcessingEnabled, setTraceLogger, sourceConnectionsOK, startEnabledEventProcessing, suspendAll, suspendEnabledEventProcessing |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NB
protected NaiveBayes NB
data
protected int[][] data
labels
protected int[] labels
nvals
protected int[] nvals
nlabels
protected int nlabels
nfeatures
protected int nfeatures
nvalues
protected int nvalues
ninst
protected int ninst
numInputs
protected int numInputs
numOutputs
protected int numOutputs
inNum
protected int[] inNum
outNum
protected double[] outNum
netMode
protected int netMode
netNumRecs
protected int netNumRecs
netRecInx
protected int netRecInx
AbleNaiveBayes
public AbleNaiveBayes()
throws AbleException
- construct an AbleNaiveBayes bean
AbleNaiveBayes
public AbleNaiveBayes(java.lang.String name)
throws AbleException
- construct an AbleNaiveBayes bean
AbleNaiveBayes
public AbleNaiveBayes(int ncls,
int nftr,
int[] nval,
int m,
double[] cpriors,
double[][][] ppriors)
throws AbleException
- construct AbleNaiveBayes bean with the explicitly specified parameters
ncls - number of class labels
nftr - number of features
nval - number of values per each feature (assuming nominal - discrete finite-valued - features)
cpriors - prior probability distribution over class labels
m - equivalent sample size
ppriors - prior estimates of the probabilities P(f|C) (used for Bayesian parameter estimation
with equivalent sample size method)
getNetMode
public int getNetMode()
getNetNumRecs
public int getNetNumRecs()
getNetRecInx
public int getNetRecInx()
setNetMode
public void setNetMode(int mode)
- train (build hypothesis) or test(classify) modes
init
public void init()
throws AbleException
- Initialize the bean
Read in the file and create the Naive Bayes Network
- Overrides:
init
in class AbleObject
- Following copied from class:
com.ibm.able.AbleObject
- Throws:
AbleException
- If an error occurs.- See Also:
AbleObject.startEnabledEventProcessing()
reset
public void reset()
- Description copied from class:
AbleObject
- Reset this bean to its "initialized" state.
This base method has no default implementation. It only provides tracing.
- Overrides:
reset
in class AbleObject
- Following copied from class:
com.ibm.able.AbleObject
- Throws:
AbleException
- If an error occurs.- See Also:
AbleBean.reset()
process
public void process()
throws AbleException
- Process a single record from the input buffer
if in train mode, add info to the network
if in test mode, classify it and place the class index in the output buffer
- Overrides:
process
in class AbleObject
- Following copied from class:
com.ibm.able.AbleObject
- See Also:
AbleObject.inputBuffer
,
AbleObject.outputBuffer
,
AbleBean.process()
processTimerEvent
public void processTimerEvent()
- Not used in this class
- Overrides:
processTimerEvent
in class AbleObject
- Following copied from class:
com.ibm.able.AbleObject
- Throws:
AbleException
- If an error occurs.
initFromImport
protected void initFromImport()
throws AbleException
- try to figure out the Bayes network architecture from an AbleImport
and DataSet object
getNClasses
public int getNClasses()
getNFeatures
public int getNFeatures()
getNFValues
public int[] getNFValues()
getEqSampleSize
public double[] getEqSampleSize()
getCPT
public double[][][] getCPT()
getClassPriors
public double[] getClassPriors()
getAvgLikelihood
public double getAvgLikelihood()
getAvgLogLikelihood
public double getAvgLogLikelihood()
getAccuracy
public double getAccuracy()
getClassProb
public double[] getClassProb()
getConfusionMatrix
public int[][] getConfusionMatrix()
setNClasses
public void setNClasses(int ncls)
setNFeatures
public void setNFeatures(int nftr,
int[] nfv)
setClassPriors
public void setClassPriors(double[] cpriors)
(C) Copyright IBM Corporation 1999, 2003