Logistic regression python solvers' definitions
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Logistic regression is a foundational statistical method used for binary classification tasks. It predicts the probability that an instance belongs to a particular category. Given its importance, several solver algorithms are available in Python's scikit-learn library to perform logistic regression. Each solver has unique properties, strengths, and shortcomings. This article provides a detailed overview of these solvers, enhancing our understanding through technical explanations and examples.
What is Logistic Regression?
Mathematically, logistic regression leverages the logistic function:
Here, is the probability that the output is 1 given input . The coefficients are estimated to maximize the likelihood of observed data.
Python Solvers for Logistic Regression
Scikit-learn's `LogisticRegression` module provides a collection of solvers catered to different types of datasets and use cases. Below are their detailed descriptions:
- liblinear • Type: Coordinate Descent Algorithm. • Use case: Suitable for smaller datasets. • Strengths: Great for L1-regularization since it handles sparsity well. • Shortcomings: Not efficient for larger datasets. It doesn't support multi-class classification with the `multi_class='multinomial'` option.Example:• Type: Newton Conjugate Gradient. • Use case: Operates well with larger datasets. • Strengths: Adequate for L2-regularization and multi-class classifications when `multi_class='multinomial'`. • Shortcomings: Complexity in implementation, might be slower. • Type: Limited-memory Broyden–Fletcher–Goldfarb–Shanno Algorithm. • Use case: Efficient with both small and large datasets. • Strengths: Supports L2-regularization and multi-class classification. Generally efficient and stable. • Shortcomings: Might consume unfamiliar systems' significant memory.• Type: Stochastic Average Gradient. • Use case: Highly efficient on very large datasets. • Strengths: Specialized for L2-regularization and very large datasets. • Shortcomings: Requires standardized data and is slow for smaller datasets. • Type: Stochastic Average Gradient with Adaptations. • Use case: Works with both L1 and L2-regularization; suitable for extremely large datasets. • Strengths: Supports sparse datasets and both L1/L2 norms. • Shortcomings: Slightly more complex, requires careful parameter tuning. • Type: Newton-Cholesky Solver. • Use case: Useful when `multi_class='multinomial'`. • Strengths: Suitable for small datasets or when high precision of the solution is needed. • Shortcomings: Not available in some older scikit-learn versions.
Related reading
- Logistic Regression using Tensorflow 2.0?
- logits and labels must be broadcastable error in Tensorflow `RNN`
- logits and labels must be broadcastable logits_size0,2 labels_size32,2
- Logloss of binary classifier with constant prediction
- \`Loss\` goes up back to starting value after re-initializing dataset
- Machine Learning Algorithm for Predicting Order of Events?
- Looking for help in making my socket messenger send instantaneously in Python
- looking for source code of from gen_nn_ops in tensorflow
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.