-
-
Notifications
You must be signed in to change notification settings - Fork 26k
Added MLPRegressor and MLPClassifier examples #15228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added MLPRegressor and MLPClassifier examples #15228
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @FollonSaxBass
@@ -875,6 +875,28 @@ class MLPClassifier(ClassifierMixin, BaseMultilayerPerceptron): | |||
out_activation_ : string | |||
Name of the output activation function. | |||
|
|||
|
|||
Examples | |||
---------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
---------- | |
-------- |
the length should match the section above it.
>>> print(clf.predict([[0.1,0.69,0.54,0.1,0.27]])) | ||
[0] | ||
|
||
>>> # Calculate accuracy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment
>>> print(clf.predict_proba([[0.1,0.4,0.54,0.1,0.27]])) | ||
[[0.64113804 0.35886196]] | ||
|
||
>>> # Predict class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment
... n_informative=2, n_redundant=3, random_state=1, shuffle=True) | ||
|
||
>>> clf = MLPClassifier(random_state=1).fit(X, y) | ||
>>> # Predict probabilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment
|
||
|
||
>>> # Calculate coefficient of determination R^2 | ||
>>> cross_val_score(clf, X, y, cv=5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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