public class Multinomial_Logistic_Regression
extends java.lang.Object
This class will create a multinomial Logistic regression algorithm where there is a set of predictors as a double [][] array and a String categorical type variable as array [] with K distinct categories ,where k>=3 (for 2 distinct categories a simple binary logistic model may be preferred).
The logic to run the algorithm will be to create K-1 Binary logistic regression models (where K is the number of distinct values of our target category) by converting the target category into binary (e.g. if it is the category we want then 1 else 0). We already know that the sum of the probabilities in all categories must be 1, therefore, by knowing the probabilities of (k-1), we can easily infer the probability of K.
The probabilities of any of the (k-1) factors-categories can be seen as the odds of an event occurring more or less than the Kth event of the factor-category that will be left aside. Therefore the probability of any of the K factors can be computed as:
P(yi=K) = eXiBK/ (1+ Ó eXiBaside) While the the probability of the K factor is : P(yi=K) = 1/ (1+ Ó eXiBK) Where B is the regerssion's coefficient , X the data attribute and i the observation.(William H. Greene, 2003/p.720-722)
| Constructor and Description |
|---|
Multinomial_Logistic_Regression() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String[] |
get_distinct_values() |
double[][] |
getbetas() |
java.lang.String[] |
getclassification(double[][] matrix)
This method will return the classification/prediction of each observation of the
provided set that may be any of the K categories of the target.
|
double |
getmaximumlikelihood() |
double[][] |
getprobabilites(double[][] matrix)
This method will return the probabilities of each observation of the
provided set to belong in any of the K categories of the target.
|
double[][] |
getwaldpvalues() |
double[][] |
getwalds() |
void |
regression(double[][] matrix,
java.lang.String[] Target)
A simpler constructor of Multinomial Logistic Regression.
|
void |
regression(double[][] matrix,
java.lang.String[] Target,
double tolerance,
int maxim_Iteration)
This is the main method that will compute the coefficients and all other stats for the Multinomial Logistic model.
|
void |
setKvalue(java.lang.String k)
This is as standard setter method for the value of the target category that will
be left aside.
|
public void setKvalue(java.lang.String k)
This is as standard setter method for the value of the target category that will be left aside. Ideally we choose the value that we would like to compare with.
k - : it is the value of the target that we would like to be left asidepublic void regression(double[][] matrix,
java.lang.String[] Target,
double tolerance,
int maxim_Iteration)
This is the main method that will compute the coefficients and all other stats for the Multinomial Logistic model. By default all the models have a constant.
matrix - : The matrix of double covariate values in [row][column] format. This is also called the "predictors' set"Target - : The categorical target String Array that needs to have more than 2 distinct categories.tolerance - : This can be interpreted as precision. That is how much we want to be the minimum change in coefficients so as to stop the algorithm.maxim_Iteration - : an integer value for allowing the algorithm to run multiple rounds in case the optimum point is not achieved earlier by setting the tolerance.public void regression(double[][] matrix,
java.lang.String[] Target)
A simpler constructor of Multinomial Logistic Regression.
matrix - : The matrix of double covariate values in [row][column] format. This is also called the "predictors' set"Target - : The categorical target String Array that needs to have more than 2 distinct categories.public double[][] getprobabilites(double[][] matrix)
This method will return the probabilities of each observation of the provided set to belong in any of the K categories of the target.
matrix - : A data set of [rows][columns] that needs to have the same format with the one used to compute the betaspublic java.lang.String[] getclassification(double[][] matrix)
This method will return the classification/prediction of each observation of the provided set that may be any of the K categories of the target.
matrix - : A data set of [rows][columns] that needs to have the same format with the one used to compute the betaspublic double[][] getbetas()
public double[][] getwalds()
public double[][] getwaldpvalues()
public double getmaximumlikelihood()
public java.lang.String[] get_distinct_values()