Skip to content

Remove validation from __init__ and set_params #21406

Description

@thomasjpfan

This issue is reserved for the Data Umbrella Africa & Middle East Sprint on October 23, 2021 as a good first issue. For non-sprint contributors, please wait till October 30, 2021 to work on this issue.

Follow up to #16945

  1. Make sure you have the development dependencies and documentation dependencies installed.
  2. Pick an from the list below and leave a comment saying you are going to work on it. This way we can keep track of what everyone is working on.
  3. Remove the estimator(s) from:

VALIDATE_ESTIMATOR_INIT = [

  1. Run the test for checking for no validation, which should fail:
pytest sklearn/tests/test_common.py::test_estimators_do_not_raise_errors_in_init_or_set_params
  1. Update the codebase so the above test passes.
  2. Open a Pull Request with an opening message Addresses #21406. Note that each item should be submitted in a separate Pull Request.
  3. Include the function name in the title of the pull request. For example: "ENH Removes validation in __init__ for _______".

Estimators on the same line should be fixed together since they share a parent class.

Activity

  1. HayaAlmutairi commented on Oct 23, 2021

    @HayaAlmutairi
    Contributor

    Me and @krumeto will work on FactorAnalysis

  2. amueller commented on Oct 23, 2021

    @amueller
    Member

    @HayaAlmutairi Can you please pick one of the estimators / check boxes above to start with, so other people can work on the other ones?

  3. DessyVV commented on Oct 23, 2021

    @DessyVV
    Contributor

    Me and @LucyJimenez will start working on KernelDensity.

  4. Haidar13 commented on Oct 23, 2021

    @Haidar13
    Contributor

    I will be working on NuSVC, NuSVR, SVC, SVR, OneClassSVM

  5. marenwestermann commented on Oct 23, 2021

    @marenwestermann
    Member

    @hhnnhh and I are working on FastICA.

  6. krumetoft commented on Oct 23, 2021

    @krumetoft
    Contributor

    Working on LabelBinarizer.

  7. DessyVV commented on Oct 24, 2021

    @DessyVV
    Contributor

    @glemaitre I think this issue got closed by mistake because of my PR. Could it be reopened?

  8. chritter commented on Oct 31, 2021

    @chritter
    Contributor

    @fortune-uwha and I will be working on RadiusNeighborsClassifier.

  9. chritter commented on Oct 31, 2021

    @chritter
    Contributor

    @thomasjpfan We noticed that the Issue title mentions get_params but the test function in test_common.py tests the get_params function. Could you clarify this? Thanks!

  10. changed the title [-]Remove validation from `__init__` and `get_params`[/-] [+]Remove validation from `__init__` and `set_params`[/+] on Oct 31, 2021
  11. thomasjpfan commented on Oct 31, 2021

    @thomasjpfan
    MemberAuthor

    We noticed that the Issue title mentions get_params but the test function in test_common.py tests the get_params function. Could you clarify this?

    Thanks for catching this. The title was wrong.

  12. chritter commented on Nov 4, 2021

    @chritter
    Contributor

    @thomasjpfan I would suggest a slight modification of the input validation test when testing set_params due to the limitation of inspect.signature which returns kwargs as a parameter if defined as **kwargs in the function signature (example for RadiusNeighborsClassifier further below). To address this, I would suggest to call get_params() to retrieve the arguments first and pass those with the test values to set_params(**new_params) as follows:

    def test_estimators_do_not_raise_errors_in_init_or_set_params(Estimator):
        """Check that init or set_param does not raise errors."""
        params = signature(Estimator).parameters
    
        smoke_test_values = [-1, 3.0, "helloworld", np.array([1.0, 4.0]), {}, []]
        for value in smoke_test_values:
            new_params = {key: value for key in params}
    
            # Does not raise
            est = Estimator(**new_params)
    
            new_params_set = {key: value for key in est.get_params()}
            # Also do does not raise
            est.set_params(**new_params_set)
    
    from sklearn.neighbors import RadiusNeighborsClassifier
    from inspect import signature
    
    clf = RadiusNeighborsClassifier()
    
    params = clf.get_params()
    param_names = [param for param in params]
    
    # signature returns **kwargs as param kwargs which is not a valid param
    # available in param_names
    param_names_sign = [param for param in signature(RadiusNeighborsClassifier
                                                ).parameters]
    
  13. 1 remaining item

  14. MrinalTyagi commented on Nov 6, 2021

    @MrinalTyagi
    Contributor

    Hi. I would like to work in SGDOneClassSVM

  15. marenwestermann commented on Nov 6, 2021

    @marenwestermann
    Member

    Working on FeatureHasher with @hhnnhh

  16. VibhutiBansal-11 commented on Nov 7, 2021

    @VibhutiBansal-11

    Hi, I am working on GridSearchCV .

  17. marenwestermann commented on Nov 14, 2021

    @marenwestermann
    Member

    I'm working on TheilSenRegressor and TweedieRegressor.

  18. iofall commented on Nov 28, 2021

    @iofall
    Contributor

    Hey @MrinalTyagi are you still working on SGDOneClassSVM?

  19. MrinalTyagi commented on Nov 29, 2021

    @MrinalTyagi
    Contributor

    Hey @MrinalTyagi are you still working on SGDOneClassSVM?

    sorry for not updating. Yes, I worked on this issue and will push it in a day.

  20. MrinalTyagi commented on Dec 4, 2021

    @MrinalTyagi
    Contributor

    Working on GridSearchCV and HalvingGridSearchCV

  21. arisayosh commented on Dec 5, 2021

    @arisayosh
    Contributor

    Taking a look at ColumnTransformer, Pipeline, FeatureUnion with @iofall

  22. added
    Moderate
    on Dec 12, 2021
  23. added
    Meta-issue
    on Mar 18, 2022
  24. marenwestermann commented on Apr 7, 2022

    @marenwestermann
    Member

    ColumnTransformer, TheilSenRegressor, and TweedieRegressor can be removed from the list.

  25. ogrisel commented on Sep 15, 2022

    @ogrisel
    Member

    This was the last! Thank you everybody!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Meta-issueModerateSprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions