Get the number of iterations in SVR
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:9 (8 by maintainers)
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 storingn_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_
Exposing
n_iter_
would be enough for the moment.