Skip to content
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

FIX - Compatibility with scikit-learn 1.2.dev #279

Closed
wants to merge 3 commits into from

Conversation

Badr-MOUFAD
Copy link
Collaborator

@Badr-MOUFAD Badr-MOUFAD commented Nov 2, 2022

scikit-learn 1.2.dev breaks down the actual code. debug_script.py provides a small snippet to reproduce.

investigation

scikit-learn seems to have added a validation step of the class parameters at the fit moment.
our Lasso estimator doesn't have the same signature as the scikit-learn (e.g. copy_X and random_state), though we inherit from it.

Therefore we get an error when comparing the constructor arguments with the parent class

click to expend error
raise ValueError(
ValueError: The parameter constraints ['alpha', 'fit_intercept', 'precompute', 'max_iter', 'copy_X', 'tol', 'warm_start', 'positive', 
'random_state', 'selection'] contain unexpected parameters {'copy_X', 'precompute', 'random_state', 'selection'}

potential fix

A straightforward fix would be to override _validate_params. But I don't think it's a reliable way to do it.

click to expend code
def _validate_params(self):
        pass

@Badr-MOUFAD Badr-MOUFAD marked this pull request as draft November 2, 2022 14:57
@@ -105,6 +107,15 @@ class Lasso(Lasso_sklearn):
http://proceedings.mlr.press/v80/massias18a.html
"""

_parameter_constraints: dict = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another fix would be to define our own parameters constraints specific to the class.

With these changes, we pass the Lasso test.

Copy link
Owner

Choose a reason for hiding this comment

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

I think it's better to have the checks than to remove _validate_data

@Badr-MOUFAD
Copy link
Collaborator Author

Closing as it's no longer a problem

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.

None yet

2 participants