public class Naive_Bayes_classifier
extends java.lang.Object
The Naive Bayes classification theorem is a mathematical logic that given a set of predictors and a target variable of distinct classes can classify a new set in one of the categories of the target based on its closenesses with the averages and variances with the latter.
Generally this classification method is quite fast as it does not require complex calculations and it still provides good classification-prediction results with big data sets.
About the Algorithm, Naive takes into account the mean and variance of all predictors in the given set and for another set -for each observation- checks which has higher probability to be the correct prediction. The formula that calculates this probability density P(x) number for a given observation is :
P(x)=Ði1/sqrt(2ðói2) * exp(-(Ti-mi)2/2ói2) where x represents the class of the target i represents the chosen predictor T the actual value of the predictor for a given observation m and ó2 are the mean and variance of each predictor for a given class
For one more time, Wikipedia is a great source and you can find more here Naive Bayes classifier
| Constructor and Description |
|---|
Naive_Bayes_classifier() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String[] |
Classify(double[][] Array)
This method will classify the given set based on the categories
|
void |
Create_Logic(double[][] Predictors,
java.lang.String[] Target)
This is the main method of this class that will create the logic that will be
used for the classification of the distinct classes of the Target.
|
double[][] |
Get_means() |
java.lang.String[] |
get_target() |
double[][] |
Get_variances() |
double[][] |
getprobabilities(double[][] Array)
This method will provide the probability of each observation to belong in each class
|
public void Create_Logic(double[][] Predictors,
java.lang.String[] Target)
This is the main method of this class that will create the logic that will be used for the classification of the distinct classes of the Target.
Predictors - : A 2 dimensional array of numeric predictors as [Row][columns]Target - : The String Array of all the classes for which we are interested in classifyingpublic double[][] Get_means()
public double[][] Get_variances()
public java.lang.String[] get_target()
public java.lang.String[] Classify(double[][] Array)
This method will classify the given set based on the categories
Array - : The new Set to be classified. It needs to have same number of columns(predictors) as in the Create_Logic method .public double[][] getprobabilities(double[][] Array)
This method will provide the probability of each observation to belong in each class
Array - : The new Set to be attributed with probabilities. It needs to have same number of columns(predictors) as in the Create_Logic method .
The form of the array is [Observation count] [Predictors count].