Skip to content

[MRG+2] Raise ValueError for metrics.cluster.supervised with too many classes - #5445

Merged
GaelVaroquaux merged 3 commits into
scikit-learn:masterfrom
tomMoral:devTom
Oct 19, 2015
Merged

GaelVaroquaux merged 3 commits into
scikit-learn:masterfrom
tomMoral:devTom

Conversation

@tomMoral

Copy link
Copy Markdown
Contributor

Fix for #4976

  • Add max_n_classes param to cluster.supervised metric
  • Add testing for the Value Error
  • Check that n_clusters,n_classes are not too high in contingency matrix

- Add testing for the Value Error
- Check that n_clusters,n_classes are not too high in contingency matrix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You seems to be above column 79 here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a 79 line I think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

my mistake

-Now the overall test time is below .2s for cluster metrics
@TomDLT

TomDLT commented Oct 19, 2015

Copy link
Copy Markdown
Member

LGTM

Comment thread sklearn/metrics/cluster/supervised.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: "number of classes", IMHO

@GaelVaroquaux GaelVaroquaux changed the title [MRG] Raise ValueError for metrics.cluster.supervised with too many classes [MRG+1] Raise ValueError for metrics.cluster.supervised with too many classes Oct 19, 2015
@GaelVaroquaux GaelVaroquaux changed the title [MRG+1] Raise ValueError for metrics.cluster.supervised with too many classes [MRG+2] Raise ValueError for metrics.cluster.supervised with too many classes Oct 19, 2015
@GaelVaroquaux

Copy link
Copy Markdown
Member

LGTM. Waiting for travis to finish and then merging.

@GaelVaroquaux

Copy link
Copy Markdown
Member

Travis ran. Merging!

GaelVaroquaux added a commit that referenced this pull request Oct 19, 2015
[MRG+2] Raise ValueError for metrics.cluster.supervised with too many classes
@GaelVaroquaux
GaelVaroquaux merged commit f6b85d9 into scikit-learn:master Oct 19, 2015
@tomMoral
tomMoral deleted the devTom branch October 19, 2015 21:38
@amueller

Copy link
Copy Markdown
Member

That's a clever way to deal with this. I'm not sure it is better than the type_of_target logic, which uses _is_integral_float, though. The issue came up because someone gave floats to the functions. And I think we should deal with this issue consistently.

@amueller

Copy link
Copy Markdown
Member

If we do keep this solution, it needs a whatsnew entry, refering to this PR and a versionadded for the option.

@jnothman

Copy link
Copy Markdown
Member

FWIW, I think this is the wrong solution, when most of those metrics should be using a sparse contingency matrix, as per #4788. (Apart from concerns like passing continuous targets by accident, there are problem setting for clustering where the assignments are very sparse, such as coreference resolution.) Would anyone mind if we deprecated max_n_classes? I think it's very obscure.

@jnothman

Copy link
Copy Markdown
Member

The issue here is really a validation issue. If someone puts continuous scores into a clustering metric we can either explicitly catch that and raise an error; otherwise, we should return a result of 0.

There are, on the other hand, real clustering problems with a large number of clusters, but any likely clustering is sparse.

@ogrisel

ogrisel commented Sep 14, 2016

Copy link
Copy Markdown
Member

For the sake of navigating between issues, a rebased version of #4788 to implement sparse contengy matrix computation has been re-submitted as #7203.

@jnothman

Copy link
Copy Markdown
Member

Never mind that, I'm about to make a PR of a more complete version of #7203.

@ogrisel

ogrisel commented Sep 14, 2016

Copy link
Copy Markdown
Member

I was about to do the same :) I will wait for yours.

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.

6 participants