scikit-image / skimage-tutorials

skimage-tutorials: a collection of tutorials for the scikit-image package.
Other
493 stars 374 forks source link

normalized image before applying LogisticRegression #68

Closed emmanuelle closed 2 years ago

emmanuelle commented 2 years ago

This change corrects a convergence warning in the logistic regression (cell 48, Exercise: the simplest neural network)

from skimage import util

windows = util.view_as_windows(img_as_float(image), (3, 3))
print(windows.shape)

(it used to be

from skimage import util

windows = util.view_as_windows(image, (3, 3))
print(windows.shape)

The convergence warning disappears when normalizing the image; the warning was

c:\users\XXX\miniconda3\lib\site-packages\sklearn\linear_model\_logistic.py:814: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
emmanuelle commented 2 years ago

@lagru this small PR solves the warning you mentioned yesterday