question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add which solver was used in sklearn Ridge regression : add clf.get_params(solver)

See original GitHub issue

Describe the issue linked to the documentation

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html

solver{‘auto’, ‘svd’, ‘cholesky’, ‘lsqr’, ‘sparse_cg’, ‘sag’, ‘saga’, ‘lbfgs’}, default=’auto’ Solver to use in the computational routines:

‘auto’ chooses the solver automatically based on the type of data.

Suggest a potential alternative/fix

add how to find which solver actually was used

for example

>>> from sklearn.linear_model import Ridge
>>> import numpy as np
>>> n_samples, n_features = 10, 5
>>> rng = np.random.RandomState(0)
>>> y = rng.randn(n_samples)
>>> X = rng.randn(n_samples, n_features)
>>> clf = Ridge(alpha=1.0)
>>> clf.fit(X, y)
Ridge()
add
clf.get_params(solver)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasjpfancommented, Jan 30, 2022

If we want to expose the selected solver, I see are two options:

  1. Set a chosen_solver_ that makes it clear what the chosen solver was.
  2. Document what “auto” means. The solver selection logic is not too complex:

https://github.com/scikit-learn/scikit-learn/blob/0dfaaadfe2d0e0b4fd9d2ba22a75b7b1b1903049/sklearn/linear_model/_ridge.py#L493-L502

To help motivate the new feature, what is your use case for knowing the chosen solver?

0reactions
RenTrieucommented, May 13, 2022

@tofetpuzo I’m not sure if there is a good way to take this offline, but perhaps we can discuss in more detail in my PR? Alternatively, if you would like to link your own PR, I would be happy to work with you there instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sklearn.linear_model.Ridge — scikit-learn 1.2.0 documentation
This model solves a regression model where the loss function is the linear least squares function and regularization is given by the l2-norm....
Read more >
sklearn.linear_model.LogisticRegression
This class implements regularized logistic regression using the 'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. Note that regularization is ...
Read more >
sklearn.linear_model.LogisticRegressionCV
This class implements logistic regression using liblinear, newton-cg, sag of lbfgs optimizer. The newton-cg, sag and lbfgs solvers support only L2 ...
Read more >
sklearn.linear_model.LinearRegression
Ridge. Ridge regression addresses some of the problems of Ordinary Least Squares by imposing a penalty on the size of the coefficients with...
Read more >
sklearn.linear_model.ridge_regression
'auto' chooses the solver automatically based on the type of data. · 'svd' uses a Singular Value Decomposition of X to compute the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found