|
ABLE 2.3.0 07/13/2005 14:21:00 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectcom.ibm.able.beans.bayes.NaiveBayes
| Field Summary | |
|---|---|
protected static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
NaiveBayes()
|
|
NaiveBayes(int ncls,
int nftr,
int[] nval,
double m,
double[] cpriors,
double[][][] ppriors)
construct NaiveBayes 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) |
|
| Method Summary | |
|---|---|
void |
buildHypothesis(int[][] data,
int[] labels,
int ninst,
int ncls,
int nftr,
int[] nval)
Build a hypothesis using explicit parameters This function learns a naive Bayes model given a set of labeled instances. |
double |
classify(int[][] data,
int[] labels,
int ninst,
boolean[] selectedFeatures)
Classify a record Input: data - training data in a table format where each row represents an instance, and each column represents an attribute (feature). |
int |
classifyExample(int[] instance,
boolean[] selectedFeatures)
This function selects the maximum-likelihood class label given a data instance Input: instance - feature vector (discrete finite feature values represented by integers) selectedFeatures - boolean array specifying selected features (by default, null -all features included) |
double[] |
findClassProbability(int[] instance,
boolean[] selectedFeatures)
This function returns the posterior probability distribution over class labels, given a data instance using Bayes rule as follows: find P(class|instance)=P(instance|class)P(class)/sum_i P(instnace|class_i) Input: instance - feature vector (discrete finite feature values represented by integers) selectedFeatures - boolean array specifying selected features (by default, null -all features included) |
double |
getAccuracy()
|
double |
getAvgLikelihood()
|
double |
getAvgLogLikelihood()
|
double[] |
getClassPriors()
|
double[] |
getClassProb()
|
int[][] |
getConfusionMatrix()
|
double[][][] |
getCPT()
|
double[] |
getEqSampleSize()
|
int |
getNClasses()
|
int |
getNFeatures()
|
int[] |
getNFValues()
|
void |
initializeNB(int ncls,
int nftr,
int[] nval,
double eqss,
double[] cpriors,
double[][][] ppriors)
internal function that implements the class construction with explicit list of 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 eqss - equivalent sample sizes for each class (by deafult, each class was seen at least once) ppriors - prior estimates of the probabilities P(f|C) (used for Bayesian parameter estimation with equivalent sample size method) |
double |
likelihood(int[] instance,
int classlabel)
Compute the likelihood of an instance given a class label |
void |
setClassPriors(double[] cpriors)
|
void |
setCPT(double[][][] cptpriors)
|
void |
setNClasses(int ncls)
|
void |
setNFeatures(int nftr,
int[] nfv)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final long serialVersionUID
| Constructor Detail |
public NaiveBayes()
public NaiveBayes(int ncls,
int nftr,
int[] nval,
double m,
double[] cpriors,
double[][][] ppriors)
throws AbleException
| Method Detail |
public void initializeNB(int ncls,
int nftr,
int[] nval,
double eqss,
double[] cpriors,
double[][][] ppriors)
throws AbleException
AbleExceptionpublic int getNClasses()
public int getNFeatures()
public int[] getNFValues()
public double[] getEqSampleSize()
public double[][][] getCPT()
public double[] getClassPriors()
public double getAvgLikelihood()
public double getAvgLogLikelihood()
public double getAccuracy()
public double[] getClassProb()
public int[][] getConfusionMatrix()
public void setNClasses(int ncls)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void setNFeatures(int nftr,
int[] nfv)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void setCPT(double[][][] cptpriors)
throws AbleException
AbleExceptionpublic void setClassPriors(double[] cpriors)
public void buildHypothesis(int[][] data,
int[] labels,
int ninst,
int ncls,
int nftr,
int[] nval)
public double classify(int[][] data,
int[] labels,
int ninst,
boolean[] selectedFeatures)
public int classifyExample(int[] instance,
boolean[] selectedFeatures)
public double[] findClassProbability(int[] instance,
boolean[] selectedFeatures)
public double likelihood(int[] instance,
int classlabel)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
|
ABLE 2.3.0 07/13/2005 14:21:00 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||