Skip to content

API Deprecate positional arguments in preprocessing#16996

Merged
adrinjalali merged 4 commits intoscikit-learn:masterfrom
thomasjpfan:keyword_only_preprocessing
Apr 23, 2020
Merged

API Deprecate positional arguments in preprocessing#16996
adrinjalali merged 4 commits intoscikit-learn:masterfrom
thomasjpfan:keyword_only_preprocessing

Conversation

@thomasjpfan
Copy link
Copy Markdown
Member

Reference Issues/PRs

Toward #15005

@thomasjpfan thomasjpfan added this to the 0.23 milestone Apr 22, 2020
Copy link
Copy Markdown
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

thanks @thomasjpfan


def __init__(self, feature_range=(0, 1), copy=True):
@_deprecate_positional_args
def __init__(self, *, feature_range=(0, 1), copy=True):
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.

I'm happy with feature_range positional or not.

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.

Positional isn't ambiguous I would say so +1 for that


def normalize(X, norm='l2', axis=1, copy=True, return_norm=False):
@_deprecate_positional_args
def normalize(X, *, norm='l2', axis=1, copy=True, return_norm=False):
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.

I'd put norm positional if we're doing positional norm in Normalizer?

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.

yes, also the names ("l2", etc) are descriptive enough


def label_binarize(y, classes, neg_label=0, pos_label=1, sparse_output=False):
@_deprecate_positional_args
def label_binarize(y, classes, *, neg_label=0, pos_label=1,
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.

should we be consistent with classes here and MultiLabelBinarizer?

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.

Went with making classes positional for now (since it is a smaller diff). But I am okay with either.

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.

Hmm I think I prefer using classes as a keyword only option. Lets see what it looks like.


def power_transform(X, method='yeo-johnson', standardize=True, copy=True):
@_deprecate_positional_args
def power_transform(X, *, method='yeo-johnson', standardize=True, copy=True):
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've not decorated the class version of this. I'm happy for methods to be positional.,..?

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.

Updated PR with the class version of this.

I'm happy for methods to be positional.,..?

I am also okay with keeping methods positional. We kind of started with making functions positional in the earlier PRs, are we okay with continuing with this?

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.

nits but LGTM anyway


def normalize(X, norm='l2', axis=1, copy=True, return_norm=False):
@_deprecate_positional_args
def normalize(X, *, norm='l2', axis=1, copy=True, return_norm=False):
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.

yes, also the names ("l2", etc) are descriptive enough


def __init__(self, n_quantiles=1000, output_distribution='uniform',
@_deprecate_positional_args
def __init__(self, n_quantiles=1000, *, output_distribution='uniform',
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.

n_quantiles is kwonly in quantile_transform (arguably because of the axis param that comes before). Should it be kwonly here too?

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.

Yea its because of the axis. I'll make it keyword only here as well.


def power_transform(X, method='yeo-johnson', standardize=True, copy=True):
@_deprecate_positional_args
def power_transform(X, *, method='yeo-johnson', standardize=True, copy=True):
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.

here again the names 'yeo-johnson' and 'boxcox' are non-ambiguous and would lead me to just not force a kwonly but no strong opinion

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.

Moved it.

def __init__(self, func=None, inverse_func=None, validate=False,

@_deprecate_positional_args
def __init__(self, func=None, *, inverse_func=None, validate=False,
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.

Suggested change
def __init__(self, func=None, *, inverse_func=None, validate=False,
def __init__(self, func=None, inverse_func=None, *, validate=False,

I assume usage would be non-ambiguous


def __init__(self, feature_range=(0, 1), copy=True):
@_deprecate_positional_args
def __init__(self, *, feature_range=(0, 1), copy=True):
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.

Positional isn't ambiguous I would say so +1 for that

Copy link
Copy Markdown
Member

@adrinjalali adrinjalali 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 minmax_scale(X, feature_range=(0, 1), axis=0, copy=True):
@_deprecate_positional_args
def minmax_scale(X, *, feature_range=(0, 1), axis=0, copy=True):
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.

should this follow the MinMaxScaler and have feature_range positional?

@adrinjalali adrinjalali merged commit e54cd3c into scikit-learn:master Apr 23, 2020
gio8tisu pushed a commit to gio8tisu/scikit-learn that referenced this pull request May 15, 2020
* API Deprecate positional arguments in preprocessing

* CLN Address comments

* CLN Uses classes as a keyword only argument

* BUG Fix
viclafargue pushed a commit to viclafargue/scikit-learn that referenced this pull request Jun 26, 2020
* API Deprecate positional arguments in preprocessing

* CLN Address comments

* CLN Uses classes as a keyword only argument

* BUG Fix
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