Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG + 1] Plot iso-f1 curves in plot_precision_recall example #8378

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

Merged
merged 1 commit into from
Feb 20, 2017

Conversation

SACHIN-13
Copy link
Contributor

Reference Issue

Fixes #8313

What does this implement/fix? Explain your changes.

While plotting PR curves, it separates out the curves with equal f1 values.

Any other comments?

An edit to my previous PR #8366

@SACHIN-13
Copy link
Contributor Author

SACHIN-13 commented Feb 16, 2017

I had removed the previous branch from my fork, so was unable to force push the changes in the same PR, my bad!
So, created a new PR with suggested changes!
Please review it.

@codecov
Copy link

codecov bot commented Feb 16, 2017

Codecov Report

Merging #8378 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #8378   +/-   ##
=======================================
  Coverage   94.75%   94.75%           
=======================================
  Files         342      342           
  Lines       60801    60801           
=======================================
  Hits        57609    57609           
  Misses       3192     3192

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8694278...a1b4837. Read the comment docs.

@SACHIN-13
Copy link
Contributor Author

screenshot from 2017-02-17 23-20-10

@SACHIN-13
Copy link
Contributor Author

Waiting for reviews!

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for your contribution!

labels = []
for F in f_scores:
x = R = np.linspace(0.01, 1)
y = F * R / (2 * R - F)
Copy link
Member

Choose a reason for hiding this comment

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

I would rather use lower case variable names for 1d vectors.

Copy link
Member

Choose a reason for hiding this comment

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

also you could use f_score instead of f maybe? And reuse x instead of R?

Copy link
Member

@raghavrv raghavrv left a comment

Choose a reason for hiding this comment

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

+1 from me once addressed...

labels = []
for F in f_scores:
x = R = np.linspace(0.01, 1)
y = F * R / (2 * R - F)
Copy link
Member

Choose a reason for hiding this comment

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

also you could use f_score instead of f maybe? And reuse x instead of R?

@raghavrv
Copy link
Member

raghavrv commented Feb 19, 2017

How does it appear on the website? I can't see the artifacts of circle ci... Ah got it (one needs to login duh!)

@raghavrv
Copy link
Member

raghavrv commented Feb 19, 2017

Can we have it (the legends) not overlapping on the curves? It looks a bit congested as such now...

Putting the legend outside the curve would be nice...

image

@raghavrv
Copy link
Member

Also can you set an alpha param to control translucency on the iso-f1?

@codecov-io
Copy link

codecov-io commented Feb 19, 2017

Codecov Report

Merging #8378 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #8378   +/-   ##
=======================================
  Coverage   94.75%   94.75%           
=======================================
  Files         342      342           
  Lines       60813    60813           
=======================================
  Hits        57621    57621           
  Misses       3192     3192

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ba84d7...0374684. Read the comment docs.

@SACHIN-13
Copy link
Contributor Author

Yes, changes made according to the reviews! I set alpha=0.2.

@jnothman
Copy link
Member

I think we should cut it back to 0.2, 0.4, 0.6, 0.8. Nine curves are too many

@SACHIN-13
Copy link
Contributor Author

okay! 👍

Copy link
Member

@raghavrv raghavrv left a comment

Choose a reason for hiding this comment

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

That's it looks good to me... Thanks! Will merge when the CIs pass...

@SACHIN-13
Copy link
Contributor Author

You're welcome :)

@SACHIN-13 SACHIN-13 changed the title plot iso-f1 curves in plot_precision_recall [MRG]plot iso-f1 curves in plot_precision_recall Feb 19, 2017
@raghavrv
Copy link
Member

The legend is still inside the plot obstructing the view. Could you move it outside please?

image

@raghavrv
Copy link
Member

Or increase the size of the plot such that it can fit into the enlarged blank space...

@raghavrv raghavrv changed the title [MRG]plot iso-f1 curves in plot_precision_recall [MRG] Plot iso-f1 curves in plot_precision_recall example Feb 19, 2017
@raghavrv raghavrv changed the title [MRG] Plot iso-f1 curves in plot_precision_recall example [MRG + 1] Plot iso-f1 curves in plot_precision_recall example Feb 19, 2017
@SACHIN-13
Copy link
Contributor Author

screenshot from 2017-02-20 02-34-32

does this look good?

@raghavrv
Copy link
Member

Perfect. Thanks!

Copy link
Member

@raghavrv raghavrv left a comment

Choose a reason for hiding this comment

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

Also can you remove the plt.show above? it makes it not to display in the docs... (it's not a part of this pr actually...)

for f_score in f_scores:
x = np.linspace(0.01, 1)
y = f_score * x / (2 * x - f_score)
l, = plt.plot(x[y >= 0], y[y >= 0], color='gray', alpha=0.2)
Copy link
Member

Choose a reason for hiding this comment

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

unneeded , ?

Copy link
Member

Choose a reason for hiding this comment

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

Also can you directly do append here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without the , , l becomes [<matplotlib.lines.Line2D object at 0x7f43d13912e8>] , which is not supported by legend (a UserWarning is raised). Using a , returns a line instance Line2D(_line3) which is what the legend function accepts! So, the lines have to be appended separately.

''.format(i, average_precision[i]))

l, = plt.plot(recall[i], precision[i], color=color, lw=lw)
lines.append(l)
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above.

@SACHIN-13
Copy link
Contributor Author

The previous curve(pr curve for class 0) is already been included in the next plot(which is being displayed in the docs).

@SACHIN-13
Copy link
Contributor Author

SACHIN-13 commented Feb 20, 2017

Had missed a legend for the "micro-average precision curve". Added it!

screenshot from 2017-02-20 08-29-55

@ogrisel
Copy link
Member

ogrisel commented Feb 20, 2017

I am still +1 for merging :)

@ogrisel
Copy link
Member

ogrisel commented Feb 20, 2017

Let's merge then.

@ogrisel ogrisel merged commit 0cae688 into scikit-learn:master Feb 20, 2017
@ogrisel
Copy link
Member

ogrisel commented Feb 20, 2017

Thanks @SACHIN-13 !

sergeyf pushed a commit to sergeyf/scikit-learn that referenced this pull request Feb 28, 2017
@Przemo10 Przemo10 mentioned this pull request Mar 17, 2017
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
lemonlaug pushed a commit to lemonlaug/scikit-learn that referenced this pull request Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot iso-F1 curves in plot_precision_recall
5 participants