bwaldvogel/liblinear-java

Java version of LIBLINEAR

What it solves

LIBLINEAR addresses the problem of training and predicting with linear models on very large datasets. Unlike kernel-based methods (like LIBSVM), linear models can efficiently handle data with many features, such as document classification, where non-linear mappings often provide little benefit. This Java port brings that capability to the JVM, enabling large-scale linear classification, regression, and outlier detection without the need for native C++ code.

How it works

The library offers two main ways to use it: command-line train and predict executables, and programmatic calls through the Linear class. It supports a variety of solver types covering different regularized loss functions — for classification (logistic regression, L1/L2-loss SVMs), regression (L2/L1-loss SVR), and one-class SVM for outlier detection. The core algorithm is a direct translation of the original C++ version, preserving the exact mathematical formulations and solver behavior. Users can configure parameters such as the cost C, the regression epsilon, the one-class SVM nu, class weights, and cross-validation options. The library also provides probability estimates for logistic regression models.

Who it’s for

Developers and data scientists working in Java who need to train or apply linear classifiers, regressors, or outlier detectors on large, high-dimensional datasets, especially those with sparse features (like text). It is also suitable for those who need to integrate a well-tested linear ML library into Java applications, or who want to compare with the original C++ LIBLINEAR due to its close code correspondence.

Highlights

  • Direct Java port of the widely-used C++ LIBLINEAR, ensuring identical mathematical behavior and easy patch updates from upstream.
  • Supports 12 solver types covering L2/L1-regularized logistic regression, support vector classification, support vector regression, and one-class SVM.
  • Provides both command-line tools (train, predict) and a simple programmatic API (Linear.train, Linear.predict, Linear.predictProbability).
  • Built for large sparse data — feature indices start at 1, and we offer options like -l 0 to preserve sparsity.
  • Includes cross-validation and automatic parameter search (-C option) to tune C and regression p.

Related

  • Project
  • Project
  • Project
  • Project