Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logistic Regression in Java

Tags:

java

We need to do a logistic regression in Java. We used this code in Python http://blog.smellthedata.com/2009/06/python-logistic-regression-with-l2.html and basically want the same thing in Java. I was directed to Weka, but the license is non-commercial.

I found the Omegahat API has the BFGS minimizer like Scipy, but I can't figure out the API: http://www.omegahat.org/api/org/omegahat/Numerics/Optimizers/OptimizerAlgorithmBFGS.html I want to implement a class with the model and put in the likelihood functions. But the model.eval takes a ModelPointNumeric which also has an eval. In any case, it is not clearly correlated with the math as the python code using numpy is. Is the omegahat api used or maintained? I could not find a mailing list for it.

like image 647
Amala Avatar asked Aug 24 '11 21:08

Amala


3 Answers

If you do not find anything else, take a look at Apache Commons Math: it is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language or Commons Lang.

Good luck.

like image 45
Guido Avatar answered Sep 19 '22 17:09

Guido


Thanks for the inputs. After much searching I found this: http://mallet.cs.umass.edu/optimization.php This is almost a 1:1 translation of how the numpy implementation works, it allows us to do logistic regression ourselves with the mathematical formulas. So I can take our python class and implement the 4-5 methods necessary and then pass it to the BFGS solver to perform our logistic regression.

It worked great, the only thing we had to realize was that Mallet maximizes the function and Numpy has a minimizer.

like image 181
Amala Avatar answered Sep 21 '22 17:09

Amala


Weka has commercial version of a license, see this page for details.

However, if logistic regression is the only data mining technique you need, take a look at LIBLINEAR, which is distributed under BSD license.

like image 39
ffriend Avatar answered Sep 17 '22 17:09

ffriend