DOC Fixed Plot Mnist Example#16200
DOC Fixed Plot Mnist Example#16200thomasjpfan merged 4 commits intoscikit-learn:masterfrom marimeireles:issue/14117
Conversation
|
Could you also say how long it takes not to run the example, and what the output is compared to what's on master? |
|
Hi @adrinjalali So this is my results after I made the model converge: Without any changes: Which is pretty much expected, IMO. Since I had to increase the number of steps so it could converge. Thanks for the feedback :) |
glemaitre
left a comment
There was a problem hiding this comment.
On the CI, it takes already 1 minute. I don't think that we should increase this time. I think that we state in the example the following:
To make the example run faster, we use very few hidden units, and train only for a very short time. Training longer would result in weights with a much smoother spatial appearance.
Thus, I would improve the discussion stating that we don't let the neural-network converge (which will issue a warning).
| y_train, y_test = y[:60000], y[60000:] | ||
|
|
||
| mlp = MLPClassifier(hidden_layer_sizes=(50,), max_iter=10, alpha=1e-4, | ||
| mlp = MLPClassifier(hidden_layer_sizes=(100,), max_iter=40, alpha=1e-4, |
There was a problem hiding this comment.
Why increasing the number of hidden layers?
There was a problem hiding this comment.
I asked around the sprint and nobody could explain me why there was a 50 in the example so I decided it was better to just use the default in the docs.
No other reason, I can change it =)
There was a problem hiding this comment.
This is to limit the complexity of the model to have a faster training from what I can see in the narration.
|
If @adrinjalali doesn't see a problem with it than I'll do it. |
|
Yeah we need to have it much faster than what it is now. It'll make the CI time out if we have a few of these slow examples. @glemaitre is also another core developer like me, you can trust him ;) I'd say we can say in the example that for performance reasons we have it like this, and that it will raise a warning, and catch the warning in the code so that running the example doesn't show the warning. Let us know if you need any help with any of that :) |
|
@adrinjalali haha it's not that I don't trust him, it's because I pinged and talked to you first. |
|
Catching the warning could be a solution with a nice comment explaining why we do so. Beter to repeat ourself :) |
|
You could also catch the warning the way we do it in # some parameter combinations will not converge as can be seen on the
# plots so they are ignored here
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=ConvergenceWarning,
module="sklearn")
mlp.fit(X, y) |
|
@marimeireles the failing check could probably be solved by a synchronisation with upstream. Could you please do this? Thanks a lot! |
|
Hi @marimeireles, hope you are doing well in those difficult times... are you still interested in finishing this PR? Thanks for the work you already did! |
|
Hey @cmarmo, thanks for reaching out again, I lost this in my backlog. |
thomasjpfan
left a comment
There was a problem hiding this comment.
Thank you for the PR @marimeireles !
| smoother spatial appearance. | ||
| smoother spatial appearance. The example will throw a warning because it | ||
| doesn't converge, in this case this is what we want because of CI's time | ||
| constringements. |
There was a problem hiding this comment.
Did you mean the following?
| constringements. | |
| constraints. |
| solver='sgd', verbose=10, random_state=1, | ||
| learning_rate_init=.1) | ||
|
|
||
| # this example won't converge because of CI's constrigements, so we catch the |
There was a problem hiding this comment.
Did you mean the following?
| # this example won't converge because of CI's constrigements, so we catch the | |
| # this example won't converge because of CI's time constraints, so we catch the |
| with warnings.catch_warnings(): | ||
| warnings.filterwarnings("ignore", category=ConvergenceWarning, | ||
| module="sklearn") | ||
|
|
||
| mlp.fit(X_train, y_train) |
There was a problem hiding this comment.
The fit needs to be indented to catch
| with warnings.catch_warnings(): | |
| warnings.filterwarnings("ignore", category=ConvergenceWarning, | |
| module="sklearn") | |
| mlp.fit(X_train, y_train) | |
| with warnings.catch_warnings(): | |
| warnings.filterwarnings("ignore", category=ConvergenceWarning, | |
| module="sklearn") | |
| mlp.fit(X_train, y_train) |
|
Would you like me to rebase these commits? |
Thanks @marimeireles! No need to rebase: core-devs will stash the commits when merging. |
adrinjalali
left a comment
There was a problem hiding this comment.
Nice, thanks @marimeireles
thomasjpfan
left a comment
There was a problem hiding this comment.
Thank you @marimeireles !


Fixes #14117
Fixes the warning about the
MLPClassifiernot being able to converge, now it does.@adrinjalali, @noatamir