public class NaiveBayes extends Object
| Modifier and Type | Field and Description |
|---|---|
HashMap<String,HashMap<String,HashMap<String,Integer>>> |
conditionalCounts |
HashMap<String,HashMap<String,HashMap<String,Float>>> |
conds |
ArrayList<ArrayList<String>> |
input |
ArrayList<String> |
labels |
HashMap<String,HashMap<String,Float>> |
means |
HashMap<String,HashMap<String,ArrayList<Float>>> |
numericValues |
HashMap<String,Integer> |
priorCounts |
HashMap<String,Float> |
priors |
HashMap<String,HashMap<String,Float>> |
ssd |
HashMap<String,HashMap<String,Float>> |
totals |
ArrayList<String> |
types |
| Constructor and Description |
|---|
NaiveBayes(String filename) |
| Modifier and Type | Method and Description |
|---|---|
void |
calcConditionals(int sum)
Compute conditionals in the format of a class name key then
the probalbities of the values for each "column" which is a
numerical key.
|
void |
calcPriors(int sum)
Calculate the prior probabilities of each class given the
numbers of instances of each class.
|
String |
classify(List<String> values)
Given the conditional and prior probabilities, and a particular
instance set of attributes, compute which class that instance is
mostly likely to fall into.
|
void |
createConditionalCounts()
Count the number of occurrences of each class.
|
void |
createMeans() |
void |
createPriorCounts()
Count the number of occurrences of each class.
|
void |
createStandardDeviation()
Note that this computes the sample standard deviation
sigma = sqrt( (1/(N-1)) sum(1,n,(xi-meanx)*(xi-meanx)))
|
void |
createTotals()
Create totals per class of each variable that is continuous.
|
int |
findTrainingSetSize() |
void |
initialize() |
static void |
main(String[] args) |
static float |
probDensFunc(float mean,
float ssd,
float x)
Compute P(x|y) given the mean, sample standard deviation and x
|
float |
probDensFunc(String clss,
String label,
float x)
Compute P(x|y) given the mean, sample standard deviation and x
|
public NaiveBayes(String filename)
public static float probDensFunc(float mean,
float ssd,
float x)
public float probDensFunc(String clss, String label, float x)
public void createPriorCounts()
public void createConditionalCounts()
public void createTotals()
public void createMeans()
public void createStandardDeviation()
public int findTrainingSetSize()
public void calcPriors(int sum)
public void calcConditionals(int sum)
public String classify(List<String> values)
public void initialize()
public static void main(String[] args)
Copyright © 2015. All rights reserved.