Skip to content
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

[MRG+1] DOC Simplifying margin plotting in SVM examples (#8501) #8875

Merged
merged 3 commits into from
Aug 1, 2017

Conversation

VathsalaAchar
Copy link
Contributor

Changes for Issue #8501

  • updated to use contour levels on decision function

  • the unbalanced class (in plot_separating_hyperplane_unbalanced.py) now uses a red line to show the change in the decision boundary when the classes are weighted

  • corrected the target variable from Y to y in other svm examples



def my_kernel(X, Y):
def my_kernel(X, y):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The y here is not the same as the y on line 20. This one should remain capitalized Y, like the kernels in the pairwise module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, I might suggest reverting all changes to this file since it does not contribute toward the goal of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made similar changes to the following:

  • examples/svm/plot_svm_nonlinear.py
  • examples/svm/plot_svm_margin.py
  • examples/svm/plot_svm_kernels.py

Do you want me to revert these as well?
I only did this for the sake of consistency with the additions I made.

@vene
Copy link
Member

vene commented Jun 5, 2017

I would suggest taking out the changes which consist only of switching y and Y, as I wrote inline as well.

In the remaining two examples (plot_separating_hyperplane.py and plot_separating_hyperplane_unbalanced.py) I like the refactored code, with the observation that you should add back the call to plt.plot() at the end. However, in case of the former, I don't like how the plot itself turns out because of make_blobs:

Before After
8875_1_before 8875_1_after
8875_2_before 8875_2_after

I like the new plot_separating_hyperplane_unbalanced but I don't like the one in the balanced case, the clusters are too loose. The plot looks too different. Could you tweak the blob radius or something?

@vene
Copy link
Member

vene commented Jun 5, 2017 via email

@VathsalaAchar
Copy link
Contributor Author

Okay, thank you very much for the review. I'll get back to you with the changes soon.

Also, how does this look for the plot_separating_hyperplane:
download

I can get them to cluster tighter if you like.

@vene
Copy link
Member

vene commented Jun 6, 2017

Strictly aesthetically I think that the old plot here was much clearer, I find the wide margin and near-vertical angle confusing here. I would not spend too much time getting it to look exactly like that, but if you could get the clusters more rotated towards the corners easily by just changing the random seed or something, it'd be great.

@VathsalaAchar VathsalaAchar force-pushed the svm_margin_plotting branch 2 times, most recently from d8d9358 to 587f11a Compare June 8, 2017 16:21
* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y
* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y
@VathsalaAchar
Copy link
Contributor Author

@vene I made the changes, how does this look?
svm

@jnothman
Copy link
Member

jnothman commented Aug 1, 2017

This LGTM

@jnothman jnothman changed the title Simplifying margin plotting in SVM examples (#8501) [MRG] DOC Simplifying margin plotting in SVM examples (#8501) Aug 1, 2017
@jnothman jnothman changed the title [MRG] DOC Simplifying margin plotting in SVM examples (#8501) [MRG+1] DOC Simplifying margin plotting in SVM examples (#8501) Aug 1, 2017
@amueller
Copy link
Member

amueller commented Aug 1, 2017

LGTM as well... and maybe, one day, we'll get a helper to create the mesh...

@amueller amueller merged commit 9927982 into scikit-learn:master Aug 1, 2017
@VathsalaAchar VathsalaAchar deleted the svm_margin_plotting branch August 2, 2017 08:25
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Aug 6, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
…#8501) (scikit-learn#8875)

* Simplifying margin plotting in SVM examples (scikit-learn#8501)

* updated to use contour levels on decision function

* separating unbalanced class now uses a red line to show the change in the decision boundary when the classes are weighted

* corrected the target variable from Y to y

* DOC Updates to SVM examples

* Fixing flake8 issues

* Altered make_blobs to move clusters to corners and be more compact

* Reverted changes converting Y to y

* Fixes for flake8 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants