Added MLPRegressor and MLPClassifier examples#15228
Added MLPRegressor and MLPClassifier examples#15228adrinjalali merged 10 commits intoscikit-learn:masterfrom
Conversation
|
|
||
|
|
||
| Examples | ||
| ---------- |
There was a problem hiding this comment.
| ---------- | |
| -------- |
the length should match the section above it.
| >>> print(clf.predict([[0.1,0.69,0.54,0.1,0.27]])) | ||
| [0] | ||
|
|
||
| >>> # Calculate accuracy |
| >>> print(clf.predict_proba([[0.1,0.4,0.54,0.1,0.27]])) | ||
| [[0.64113804 0.35886196]] | ||
|
|
||
| >>> # Predict class |
| ... n_informative=2, n_redundant=3, random_state=1, shuffle=True) | ||
|
|
||
| >>> clf = MLPClassifier(random_state=1).fit(X, y) | ||
| >>> # Predict probabilities |
|
|
||
|
|
||
| >>> # Calculate coefficient of determination R^2 | ||
| >>> cross_val_score(clf, X, y, cv=5) |
There was a problem hiding this comment.
Maybe just clf.score(X, y) I'm not sure that doing cross validation with 20 samples is ideal anyway.
|
In general, please remove all more obvious comments in thee added examples. e.g. when running |
|
Thanks for your comments @rth, going to commit changes. |
|
Hi @rth @FollonSaxBass , I have mentioned one week before at #3846 that I will be working on it and I have already started working on it. |
|
Hi @PyExtreme, I didn't wanted to "stole" your pr. It's my first contribution and I saw that your message was like 5 days ago without any pr. Therefore, I started working on the issue watching carefully if you were submitting a PR. It takes like 20 mins to add these comments so I thought you were not working on it anymore. Hope this does not create any problem to you. |
@FollonSaxBass , I had got occupied after doing inital work. But since, it's your first PR, Please go ahead. Also, Please do mention on the issue, the classes you will be picking so as to avoid any conflict. Cheers |
|
@PyExtreme ok, thanks, I'm sorry for bothering you, I sincerely didn't think you were working on it :) Now the PR is visible on the thread and i think none will work on it anymore. Regards |
|
@rth do you have any further suggestion? |
|
@rth after a bit of time I'm back to ask, Is there any problem with this pr? :) |
thomasjpfan
left a comment
There was a problem hiding this comment.
Thank you for the PR @FollonSaxBass !
| >>> from sklearn.neural_network import MLPClassifier | ||
| >>> from sklearn.datasets import make_classification | ||
|
|
||
| >>> X, y = make_classification(n_samples=1000, n_features=5, |
There was a problem hiding this comment.
I would prefer less keywords here to focus on the MLP part of the example:
X, y = make_classification(random_state=1)
clf = MLPClassifier(random_state=1, max_iter=300).fit(X, y)
clf.predict_proba(X[:2, :])
...| >>> from sklearn.neural_network import MLPRegressor | ||
| >>> from sklearn.datasets import make_regression | ||
|
|
||
| >>> X, y = make_regression(n_samples=20, n_features=5, random_state=1) |
There was a problem hiding this comment.
@adrinjalali this one is still open
@FollonSaxBass
Did the last suggestions you got make sense to you? Will you be be able to work on them?
There was a problem hiding this comment.
Oh wow, sorry for the delay (i didn't notice the suggestions), I'll push the fix as soon as possible (during the weekend).
|
@thomasjpfan I cannot understand why circleci fails. Any suggestion? (DOC should be fixed as you suggested) |
adrinjalali
left a comment
There was a problem hiding this comment.
LGTM, thanks @FollonSaxBass
* Added MLPRegressor and MLPClassifier examples * shortened line due to test failure * changed way to calculate score due to approximation error in tests * removed comments, used predict instead of cross validation * DOC Simplified make_regression and make_classification arguments * DOC fix for linting * DOC Update * DOC Less precision Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
Issue #3846
What does this implement/fix?
Simple examples have been added for both neural_network.MLPRegressor and neural_network.MLPClassifier