October 20th, Q&A session: Get you issues solved and questions answered!

GitHub logo

Logistic Regression

Binary Logistic Regression is a special type of regression where a binary response variable is related to a set of explanatory variables, which can be discrete and/or continuous. The important point here to note is that in linear regression, the expected values of the response variable are modeled based on a combination of values taken by the predictors. In logistic regression Probability or Odds of the response taking a particular value is modeled based on the combination of values taken by the predictors. In the Apache Ignite ML module it is implemented via LogisticRegressionModel that solves the binary classification problem. It is a linear method with the loss function in the formulation given by the logistic loss:

logistic regression

For binary classification problems, the algorithm outputs a binary logistic regression model. Given a new data point, denoted by x, the model makes predictions by applying the logistic function:

logistic regression2

By default, if f(wTx)>0.5 or \mathrm{f}(\wv^T x) > 0.5 (Tex formula), the outcome is positive, or negative otherwise. However, unlike linear SVMs, the raw output of the logistic regression model f(z) has a probabilistic interpretation (i.e., the probability that it is positive).


The model is represented by the class LogisticRegressionModel and keeps the weight vector. It enables a prediction to be made for a given vector of features, in the following way:

LogisticRegressionModel mdl = ;

double prediction = mdl.predict(observation);

Ignite supports several parameters for LogisticRegressionModel:

  • isKeepingRawLabels - controls the output label format: 0 and 1 for false value and raw distances from the separating hyperplane otherwise (default value: false)

  • threshold - a threshold to assign label ‘1’ to the observation if the raw value is more than this threshold (default value: 0.5)

LogisticRegressionModel mdl = ;

double prediction = mdl.withRawLabels(true).withThreshold(0.5).predict(observation);


Trainer of the binary logistic regression model builds a MLP 1-level trainer under the hood.

Ignite supports the following parameters for LogisticRegressionSGDTrainer:

  • updatesStgy - update strategy

  • maxIterations - max amount of iterations before convergence

  • batchSize - the size of learning batch

  • locIterations - the amount of local iterations of SGD algorithm

  • seed - seed value for internal random purposes to reproduce training results

Set up the trainer:

LogisticRegressionSGDTrainer trainer = new LogisticRegressionSGDTrainer()

// Build the model
LogisticRegressionModel mdl = trainer.fit(ignite, dataCache, vectorizer);


To see how LogRegressionMultiClassModel can be used in practice, try this example, available on GitHub and delivered with every Apache Ignite distribution.