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

Skip to content

ENH Move non-data transform() parameters to the object #1975

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

Closed
jnothman opened this issue May 20, 2013 · 7 comments
Closed

ENH Move non-data transform() parameters to the object #1975

jnothman opened this issue May 20, 2013 · 7 comments
Labels
Easy Well-defined and straightforward way to resolve Enhancement

Comments

@jnothman
Copy link
Member

To be used sensibly in a Pipeline / parameter search, an estimator's transform method can't have parameters other than the data (though it may be possible in the future to support more than one data argument). Rather, it should be possible to set the parameter using the estimator's set_params method as used in a parameter search.

Hence additional arguments to transform should become object parameters (though whether they should be made unavailable as arguments directly to transform is up for debate).

Unfortunately, these happen to appear in mixin classes, meaning a lot of sub-classes' docstrings need altering.

Examples of additional arguments:

@jnothman
Copy link
Member Author

When this is fixed for feature_selection.from_model._LearntSelectorMixin, that should be modified to include mixin feature_selection.base.SelectorMixin.

@Hasil-Sharma
Copy link
Contributor

Can I take up this issue ?

@maniteja123
Copy link
Contributor

Hi, it seems that the issue has been fixed for AgglomerativeClustering. But the issue seems to be still persisting for _LearntSelectorMixin and seems for SparsePCA in here. In case anyone is working on this, I would gladly step aside !

In the _LearntSelectorMixin, the threshold parameter is right now passed to the transform function. When is mentioned that

should have selection_threshold parameter on object

is it expected to be a class variable for this Mixin or the base class SelectorMixin ?

Also there is a comment mentioning that

Note because of the extra threshold parameter in transform, this does
not naturally extend from SelectorMixin

Pardon my ignorance regarding the structure of classes, but which would be the best place to put the threshold option ?

Thanks.

@jnothman
Copy link
Member Author

jnothman commented Jan 3, 2016

_LearntSelectorMixin is deprecated, so not applicable either.

On 4 January 2016 at 01:06, Maniteja Nandana [email protected]
wrote:

Hi, it seems that the issue has been fixed for AgglomerativeClustering.
But the issue seems to be still persisting for _LearntSelectorMixin and
seems for SparsePCA in here
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/decomposition/sparse_pca.py#L133.
In case anyone is working on this, I would gladly step aside !

In the _LearntSelectorMixin, the threshold parameter is right now passed
to the transform function. When is mentioned that

should have selection_threshold parameter on object

is it expected to be a class variable for this Mixin or the base class
SelectorMixin ?

Also there is a comment mentioning that

Note because of the extra threshold parameter in transform, this does not
naturally extend from SelectorMixin

Pardon my ignorance regarding the structure of classes, but which would be
the best place to put the threshold option ?

Thanks.


Reply to this email directly or view it on GitHub
#1975 (comment)
.

@maniteja123
Copy link
Contributor

Thanks. I realized that it was not exposed on the public API but thought that it needs to be fixed since it is being used in other places. Sorry for not thinking over it.

@amueller
Copy link
Member

amueller commented Oct 7, 2016

@jnothman should we close this? Or first check if any models still have that with inspect?

@jnothman
Copy link
Member Author

jnothman commented Oct 8, 2016

Apart from a number of copy instances, a git grep 'def transform' quickly shows one remaining:

sklearn/decomposition/sparse_pca.py:    def transform(self, X, ridge_alpha=None):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Well-defined and straightforward way to resolve Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants