Skip to content

Commit

Permalink
Improve warning message when QN solver reaches max_iter (#3515)
Browse files Browse the repository at this point in the history
closes #2546

This PR improves the warning message printed when max iterations are reached during fitting a linear model.

Example:
```python
import numpy as np
from cuml.linear_model import LogisticRegression
from sklearn.datasets import load_breast_cancer
X, y = load_breast_cancer(return_X_y=True)
y = y.astype(np.float64)
cls = LogisticRegression(penalty='none', C=1)
cls.fit(X, y)
```
This produces the following output, where the last line is added by this PR:
```
[W] [15:31:04.467478] L-BFGS: max iterations reached
[W] [15:31:04.467804] Maximum iterations reached before solver is converged. To increase model accuracy you can increase the number of iterations (max_iter) or improve the scaling of the input data.
```

Authors:
  - Tamas Bela Feher (@tfeher)

Approvers:
  - Dante Gama Dessavre (@dantegd)

URL: #3515
  • Loading branch information
tfeher authored Feb 19, 2021
1 parent 430593d commit d393e1e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cpp/src/glm/qn/qn_solvers.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ inline int qn_minimize(const raft::handle_t &handle, SimpleVec<T> &x, T *fx,

CUML_LOG_DEBUG("OWL-QN Done");
}
if (ret == OPT_MAX_ITERS_REACHED) {
CUML_LOG_WARN(
"Maximum iterations reached before solver is converged. To increase "
"model accuracy you can increase the number of iterations (max_iter) or "
"improve the scaling of the input data.");
}
return ret;
}

Expand Down

0 comments on commit d393e1e

Please sign in to comment.