[MRG] Improve performance of the plot_rbm_logistic_classification.py example (#13383)#13648
Conversation
jnothman
left a comment
There was a problem hiding this comment.
I'd be happy to merge this and consider other changes separately...
|
Thanks @jnothman! I didn't want to spam the PR list, but I agree that it will be clearer to have one PR for each time-consuming example. I'm updating the title of this PR. |
|
Out of curiosity, what are your results for the following parameters? logistic = linear_model.LogisticRegression(solver='lbfgs', tol=1,
max_iter=1000,
multi_class='multinomial') |
|
Thanks a lot @thomasjpfan for your very good point. Using Using Metrics computed on the whole test set stay the same between the 3 sets of arguments. But there are some slight differences at the class level. Original example: Your suggestion: My suggestion: Do you prefer to stick to |
|
b94d71d sets |
Changing the tol depending on solver is actively being discussed :)
I am okay with this. |
…on.py example (scikit-learn#13383) (scikit-learn#13648)" This reverts commit 8429b27.
…on.py example (scikit-learn#13383) (scikit-learn#13648)" This reverts commit 8429b27.
Reference Issues/PRs
Partial fix to #13383
What does this implement/fix? Explain your changes.
The example
examples/neural_networks/plot_rbm_logistic_classification.pymentioned in #13383 takes a total of 32.5 seconds to build in html (on my computer). By replacing the solver used in the logistic regression fromlbfgstonewton-cg, the example took 22.0 seconds to build.The LogisticRegression is trained twice, once on RBM features in a pipeline and once on raw pixel features, but only the first one is time-consuming because of a slow convergence.
lbfgstook 4474 iterations to converge, whereasnewton-cgconverges in 43 iterations.The performance metrics are exactly similar for the logistic regression using RBM features (at the reported precision). Only very slight differences occur in metrics of the logistic regression trained on raw pixel features (highlighted below).
Any other comments?
newton-cgwas the quicker compatible solver to trained the logistic regression on RBM features. Below are the times it took to train it:I welcome any other idea that may save more time on this example.