ABLE 2.3.0 07/13/2005 14:21:00

com.ibm.able.beans.knn
Class AbleNaiveBayesDistributed

java.lang.Object
  extended bycom.ibm.able.AbleObject
      extended bycom.ibm.able.beans.knn.AbleNaiveBayesDistributed
All Implemented Interfaces:
AbleBean, AbleDataBufferManager, AbleEventListener, AbleEventListenerManager, AbleEventQueueManager, AbleEventQueueProcessor, AblePropertyChangeManager, AbleSerializable, AbleTranslateTemplateProvider, java.io.Serializable

public class AbleNaiveBayesDistributed
extends AbleObject
implements AbleTranslateTemplateProvider, java.io.Serializable

See Also:
Serialized Form

Field Summary
static java.lang.String defaultName
          Value assigned to name by default.
 double[] inNum
          The numeric input buffer.
static java.lang.String[] MODE_NAMES
          Labels for the train, test and run modes for GUI use.
 double[] outNum
          The numeric output buffer.
static int RUN
          Application or Run mode output is produced.
static int TEST
          Test mode performance is tested (errors are computed).
static int TRAIN
          Training mode training data is stored.
 
Fields inherited from class com.ibm.able.AbleObject
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, properties, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace
 
Constructor Summary
AbleNaiveBayesDistributed()
          Default constructor.
AbleNaiveBayesDistributed(java.lang.String aName)
          Construct a naive bayes bean with specified name.
AbleNaiveBayesDistributed(java.lang.String aName, int args)
           
 
Method Summary
 void calcPosteriorProb()
           
 double[] calcPriorClassProb()
           
 void calcPriorProb()
           
 void generateTranslateTemplates(AbleFilter inFilt, AbleFilter outFilt, java.util.Vector fields)
          Populate a filter for converting data to a bean's input specifications, and a filter for converting a bean's output specifications back to the original coordinates.
 double getAccuracy()
          Get the accuracy.
 double getClass(double[] x)
          Find to which class the current test example is assigned by Naive Bayes algorithm.
 double getCurrentActualClass()
          Get the current actual classes corresponding to the current test example.
 double getCurrentLearnedClass()
          Get the current learned classes corresponding to the current test/run example.
 double[] getCurrentTestExample()
          Get the current test example.
 double[] getCurrentTrainExample()
          Get the current training example.
 AttributeValueClass getElement(java.util.Vector v, int attr, int val, int cl)
           
 double getError()
          Get the error.
 java.util.Hashtable[] getFieldValues()
           
 double[] getInNum()
           
 int getM()
          Get m parameter.
 int getMaxProbIndex(double[] prob)
          Given a Vector distance populated with distances between current test example and all the training examples, get the index of the training example with the smallest distance to the test example.
 int getNaiveBayesMode()
          Get the current operating mode of the naive bayes bean.
 int getNumAttributes()
          Get numAttr parameter.
 int getNumClasses()
          Get numClasses parameter.
 long getNumCorrectTestExamples()
          Get the number of correctly classified test examples.
 int GetNumInstances(int clasS)
           
 long getNumRecords()
          Get numRecords parameter.
 long getNumTestExamples()
          Get the number of test examples seen so far.
 double[] getOutNum()
           
 java.util.Vector getTable()
           
 void init()
          Get ready to process - init all the bean members.
 void process()
          Performs the main, synchronous, standard processing function performed by this bean.
 void reset()
          Reset the naive bayes bean.
 java.util.Vector setAllTable()
           
protected  void setDefaults()
          Set up the event queue behavior.
 void setNaiveBayesMode(int mode)
          Set the operating mode of the naive bayes bean.
 void setNaiveBayesParameters(int newAttr, int newCl, long newRec)
          Set the number records, number attributes and number classes for naive bayes bean.
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsString, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsString, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getProperties, getProperty, getPropertyChangeListeners, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, getTraceLogger, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, process, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, processTimerEvent, quitAll, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllConnections, removeAllPropertyConnections, removeDestBufferConnection, removeProperty, 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, setProperties, setProperty, 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
 

Field Detail

defaultName

public static final java.lang.String defaultName
Value assigned to name by default.

See Also:
Constant Field Values

inNum

public double[] inNum
The numeric input buffer.


outNum

public double[] outNum
The numeric output buffer.


TRAIN

public static final int TRAIN
Training mode training data is stored.

See Also:
Constant Field Values

TEST

public static final int TEST
Test mode performance is tested (errors are computed).

See Also:
Constant Field Values

RUN

public static final int RUN
Application or Run mode output is produced.

See Also:
Constant Field Values

MODE_NAMES

public static final java.lang.String[] MODE_NAMES
Labels for the train, test and run modes for GUI use.

Constructor Detail

AbleNaiveBayesDistributed

public AbleNaiveBayesDistributed()
                          throws AbleException
Default constructor.


AbleNaiveBayesDistributed

public AbleNaiveBayesDistributed(java.lang.String aName)
                          throws AbleException
Construct a naive bayes bean with specified name.

Parameters:
aName - The object name

AbleNaiveBayesDistributed

public AbleNaiveBayesDistributed(java.lang.String aName,
                                 int args)
                          throws AbleException
Method Detail

getInNum

public double[] getInNum()

getOutNum

public double[] getOutNum()

setDefaults

protected void setDefaults()
                    throws AbleException
Set up the event queue behavior. No timer processing and no asynch event processing.

Throws:
AbleException

getNaiveBayesMode

public int getNaiveBayesMode()
Get the current operating mode of the naive bayes bean.

Returns:
int.

setNaiveBayesMode

public void setNaiveBayesMode(int mode)
Set the operating mode of the naive bayes bean.

Parameters:
mode - The current operating mode, train/test/run

setNaiveBayesParameters

public void setNaiveBayesParameters(int newAttr,
                                    int newCl,
                                    long newRec)
Set the number records, number attributes and number classes for naive bayes bean.

Parameters:
newAttr - Defines the number of attributes.
newCl - Defines the number of classes.
newRec - Defines the number of records.

getM

public int getM()
Get m parameter.


getNumRecords

public long getNumRecords()
Get numRecords parameter.


getNumAttributes

public int getNumAttributes()
Get numAttr parameter.


getNumClasses

public int getNumClasses()
Get numClasses parameter.


getNumTestExamples

public long getNumTestExamples()
Get the number of test examples seen so far.


getNumCorrectTestExamples

public long getNumCorrectTestExamples()
Get the number of correctly classified test examples.


getAccuracy

public double getAccuracy()
Get the accuracy.


getError

public double getError()
Get the error.


getCurrentTrainExample

public double[] getCurrentTrainExample()
Get the current training example.


getCurrentTestExample

public double[] getCurrentTestExample()
Get the current test example.


getCurrentLearnedClass

public double getCurrentLearnedClass()
Get the current learned classes corresponding to the current test/run example.


getCurrentActualClass

public double getCurrentActualClass()
Get the current actual classes corresponding to the current test example.


getTable

public java.util.Vector getTable()

init

public void init()
          throws AbleException
Get ready to process - init all the bean members.

Specified by:
init in interface AbleBean
Overrides:
init in class AbleObject
Throws:
AbleException - If an error occurs.
See Also:
AbleObject.startEnabledEventProcessing()

reset

public void reset()
           throws AbleException
Reset the naive bayes bean.

Specified by:
reset in interface AbleBean
Overrides:
reset in class AbleObject
Throws:
AbleException - If an error occurs.
See Also:
AbleBean.reset()

getMaxProbIndex

public int getMaxProbIndex(double[] prob)
Given a Vector distance populated with distances between current test example and all the training examples, get the index of the training example with the smallest distance to the test example.


getElement

public AttributeValueClass getElement(java.util.Vector v,
                                      int attr,
                                      int val,
                                      int cl)

getClass

public double getClass(double[] x)
                throws AbleException
Find to which class the current test example is assigned by Naive Bayes algorithm.

Throws:
AbleException

getFieldValues

public java.util.Hashtable[] getFieldValues()
                                     throws AbleException
Throws:
AbleException

calcPriorClassProb

public double[] calcPriorClassProb()
                            throws AbleException
Throws:
AbleException

setAllTable

public java.util.Vector setAllTable()
                             throws AbleException
Throws:
AbleException

calcPriorProb

public void calcPriorProb()
                   throws AbleException
Throws:
AbleException

GetNumInstances

public int GetNumInstances(int clasS)

calcPosteriorProb

public void calcPosteriorProb()
                       throws AbleException
Throws:
AbleException

process

public void process()
             throws AbleException
Description copied from class: AbleObject
Performs the main, synchronous, standard processing function performed by this bean.

This base method implementation provides tracing only.

Specified by:
process in interface AbleBean
Overrides:
process in class AbleObject
Throws:
AbleException
See Also:
AbleObject.inputBuffer, AbleObject.outputBuffer, AbleBean.process()

generateTranslateTemplates

public void generateTranslateTemplates(AbleFilter inFilt,
                                       AbleFilter outFilt,
                                       java.util.Vector fields)
                                throws AbleException
Description copied from interface: AbleTranslateTemplateProvider
Populate a filter for converting data to a bean's input specifications, and a filter for converting a bean's output specifications back to the original coordinates. Translate templates are added to each filter for each field as appropriate for its field usage and datatype. A bean who wishes to provide only default templates can use the static link provided in AbleFilter.generateTranslateTemplates(com.ibm.able.beans.filter.AbleFilter, com.ibm.able.beans.filter.AbleFilter, java.util.Vector)

Specified by:
generateTranslateTemplates in interface AbleTranslateTemplateProvider
Parameters:
inFilt - The AbleFilter used to convert incoming data.
outFilt - The AbleFilter used to convert outgoing data.
fields - A vector of AbleFields from which to derive the translation template.
Returns:
An array containing two AbleFilter objectshe translation template.
Throws:
AbleException

ABLE 2.3.0 07/13/2005 14:21:00

(C) Copyright IBM Corporation 1999, 2005