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.

Get the number of iterations in SVR

See original GitHub issue

Describe the workflow you want to enable

Hi everyone,

I am manipulating SVR objects in GridSearcheCV. I am able to access the mean_fit_time in the cv_results_, but I can’t access the number of iterations of the optimization problem.

I would like to have this information to properly set the max_iter parameter of the GridSearch.

Describe your proposed solution

I have tried the following:

from sklearn.svm import SVR
from sklearn.datasets import load_boston

# Load data
X, y = load_boston(return_X_y=True)

# Model test
model = SVR(verbose=4)
model.fit(X, y)

[LibSVM]* optimization finished, #iter = 351 obj = -3012.975812, rho = -21.172739 nSV = 499, nBSV = 431 Out[1]: SVR(gamma=1.0, verbose=4)

I am interested in getting the #iter field here. It should be available as a property of the model once fitted, and all number of iterations should appear somewhere in the cv_results_.

Also, please not that this feature should be available for all libsvm-based SVM objects: SVC, SVR, etc…

Additional context

I am running this code on: Python 3.7.3 scikit-learn 0.23.1

Thanks by advance for your support.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasHugcommented, Nov 27, 2020

I don’t know why we don’t expose n_iter (it’s possible that LibSVM makes it hard for us).

Regarding GridSearch: attributes aren’t stored in cv_results. We can’t store fitted models there because that would mean storing n_param_candidates * n_folds models, which can be prohibitively expensive in terms of memory.

You can however access the attributes of the final fitted model from gs.best_estimator_

0reactions
glemaitrecommented, Oct 20, 2021

Exposing n_iter_ would be enough for the moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Knowing the number of iterations needed for convergence in ...
If you want to see the progress of your SVR, enter verbose=2 to the constructor of SVR - notice this can make progress...
Read more >
Knowing the number of iterations needed for ... - YouTube
python: Knowing the number of iterations needed for convergence in SVR scikit-learnThanks for taking the time to learn more.
Read more >
sklearn.svm.SVR — scikit-learn 1.2.0 documentation
New in version 1.0. Number of iterations run by the optimization routine to fit the model. New in version 1.1. Number of support...
Read more >
Comparison of the number of iterations under GA-SVR and ...
... GA-SVR and GA-PSO-SVR are similar in accuracy, there is a large difference in the number of iterations to find the optimal solution....
Read more >
Scikit Learn - Support Vector Machines - Tutorialspoint
Value -1 means there is no limit on the number of iterations. ... Now, once fitted, we can get the weight vector with...
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