Skip to content

API kwonly args in manifold, metrics, mixture, model_selection, multclass, multioutput#16982

Merged
NicolasHug merged 10 commits intoscikit-learn:masterfrom
adrinjalali:kwarg/m
Apr 24, 2020
Merged

API kwonly args in manifold, metrics, mixture, model_selection, multclass, multioutput#16982
NicolasHug merged 10 commits intoscikit-learn:masterfrom
adrinjalali:kwarg/m

Conversation

@adrinjalali
Copy link
Copy Markdown
Member

Towards #15005

Making groups may be controversial, but I find it sometimes ambiguous when we could have either sample_weight or groups. That made the diff larger than I intended.

Our CI is probably gonna fail on the docs here, but before I go ahead with the rest of it, it'd be nice to have some feedback.

ping @jnothman @thomasjpfan @NicolasHug

@adrinjalali adrinjalali added this to the 0.23 milestone Apr 21, 2020
Copy link
Copy Markdown
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @adrinjalali

Made comments but LGTM when green anyway

I'm fine with groups being kwonly. It might make things easier if one day we want to integrate them into fit_params

# It's okay to evaluate regression metrics on classification too
mse_scorer = check_scoring(est, 'neg_mean_squared_error')
r2_scorer = check_scoring(est, 'r2')
mse_scorer = check_scoring(est, scoring='neg_mean_squared_error')
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.

this is another case that seems a bit verbose

Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Big one!


def __init__(self, fpr, tpr, roc_auc, estimator_name):
@_deprecate_positional_args
def __init__(self, *, fpr, tpr, roc_auc, estimator_name):
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.

  • after tpr

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd agree that putting * after precision and recall would maybe be ok since the class is called PrecisionRecall..., but here there's no way to know which one's supposed to come first.

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.

Actually, not sure. Because the order it comes first in corresponds to roc_curve output, so it should be easy to use RocCurveDisplay(*roc_curve_output, ...)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but not sure how many people would write it as you suggest, and it probably looks a bit cryptic to most people.


def split(self, X, y=None, groups=None):
@_deprecate_positional_args
def split(self, X, y=None, *, groups=None):
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.

Not sure how valuable it is to make groups kwonly in a method that currently always takes <=3 params

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My thinking was that very often the third argument after X, y is sample_weight, and this removes that ambiguity.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On the other hand, it seems at least we internally heavily pass groups as a positional arg. So I guess that itself is a verdict that it's breaking too much code. I'll revert this one.

@jnothman
Copy link
Copy Markdown
Member

Failures

@adrinjalali
Copy link
Copy Markdown
Member Author

I think it's green now? Can't really tell what it's complaining about.

Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM


def __init__(self, fpr, tpr, roc_auc, estimator_name):
@_deprecate_positional_args
def __init__(self, *, fpr, tpr, roc_auc, estimator_name):
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.

Actually, not sure. Because the order it comes first in corresponds to roc_curve output, so it should be easy to use RocCurveDisplay(*roc_curve_output, ...)

@jnothman
Copy link
Copy Markdown
Member

GitHub's Approve button is making errors for me. I approve.

@NicolasHug NicolasHug merged commit 02309ff into scikit-learn:master Apr 24, 2020
@NicolasHug
Copy link
Copy Markdown
Member

Thanks @adrinjalali

@adrinjalali adrinjalali deleted the kwarg/m branch April 27, 2020 18:31
gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants