Skip to content

Minimize validation of X in ensembles with a base estimator #7768

Closed

Description

@jnothman

Currently AdaBoost* requires X to be an array or sparse matrix of numerics. However, since the data is not processed directly by AdaBoost* but by its base estimator (on which fit, predict_proba and predict may be called), we should not need to constrain the data that much, allowing for X to be a list of text blobs or similar.

Similar may apply to other ensemble methods.

Derived from #7767.

Activity

  1. added
    Moderate
    on Oct 27, 2016
  2. chkoar commented on Oct 31, 2016

    @chkoar
    Contributor

    That could be applied to any meta-estimator that uses a base estimator, right?

  3. jnothman commented on Nov 1, 2016

    @jnothman
    MemberAuthor

    Yes, it could be. I didn't have time when I wrote this issue to check the applicability to other ensembles.

  4. changed the title [-]Minimize validation of X in AdaBoost[/-] [+]Minimize validation of X in ensembles with a base estimator[/+] on Nov 1, 2016
  5. jnothman commented on Nov 1, 2016

    @jnothman
    MemberAuthor

    Updated title and description

  6. chkoar commented on Nov 1, 2016

    @chkoar
    Contributor

    @jnothman I think that we have two options.

    • Validate the input early as it is now and introduce a new parameter check_input in fit, predict, etc with default vaule True in order to preserve the current behavior. The check_input could be in the constrcutor.
    • Relax the validation in the ensemble and let base estimator to handle the validation.

    What do you think? I'll sent a PR.

  7. jnothman commented on Nov 1, 2016

    @jnothman
    MemberAuthor

    IMO assuming the base estimator manages validation is fine.

  8. Chaitya62 commented on Dec 1, 2016

    @Chaitya62

    Is this still open ? can I work on it?

  9. chkoar commented on Dec 1, 2016

    @chkoar
    Contributor

    @Chaitya62 I didn't have the time to work on this. So, go ahead.

  10. Chaitya62 commented on Dec 1, 2016

    @Chaitya62

    @chkoar onit!

  11. Chaitya62 commented on Dec 4, 2016

    @Chaitya62

    After reading code for 2 days and trying to understand what actually needs to be changed I figured out that in that a call to check_X_y is being made which is forcing X to be 2d now for the patch should I do what @chkoar suggested ?

  12. jnothman commented on Dec 4, 2016

    @jnothman
    MemberAuthor
  13. Chaitya62 commented on Dec 4, 2016

    @Chaitya62

    Cool I ll submit a PR soon

  14. 4 remaining items

  15. dalmia commented on Feb 1, 2017

    @dalmia
    Contributor

    @Chaitya62 Thanks!

  16. gokart23 commented on Sep 13, 2018

    @gokart23

    I'd like to work on this, if that's ok

  17. gokart23 commented on Sep 13, 2018

    @gokart23

    As a first step, I tried looking at the behavior of meta-estimators when passed a 3D tensor. Looks like almost all meta-estimators which accept a base estimator fail :

    >>> pytest -sx -k 'test_meta_estimators' sklearn/tests/test_common.py
    <....>
    AdaBoostClassifier raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    AdaBoostRegressor raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    BaggingClassifier raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    BaggingRegressor raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    ExtraTreesClassifier raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    ExtraTreesRegressor raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    
    Skipping GradientBoostingClassifier - 'base_estimator' key not supported
    Skipping GradientBoostingRegressor - 'base_estimator' key not supported
    IsolationForest raised error 'default contamination parameter 0.1 will change in version 0.22 to "auto". This will change the predict method behavior.' when parsing data   
    
    RANSACRegressor raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data                                     
    RandomForestClassifier raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    RandomForestRegressor raised error 'Found array with dim 3. Estimator expected <= 2.' when parsing data
    

    @jnothman @amueller considering this, should this be a WONTFIX, or should all the meta-estimators be fixed?

  18. jnothman commented on Sep 15, 2018

    @jnothman
    MemberAuthor
  19. chkoar commented on Feb 14, 2019

    @chkoar
    Contributor

    @jnothman Adaboost tests are testing the sparsity of the X. This means that we should skip these tests in order to relax the validation, right?

  20. jnothman commented on Feb 14, 2019

    @jnothman
    MemberAuthor
  21. jilt-sebastian commented on Mar 21, 2019

    @jilt-sebastian

    @jnothman Could you please tell me the solution you landed on? I am working with CNNs as my weak classifiers for which the input features need to be 3D. I still face the same issue as referenced in #7767.

  22. jnothman commented on Mar 21, 2019

    @jnothman
    MemberAuthor

    Please give code that shows the error you encounter

  23. jilt-sebastian commented on Mar 21, 2019

    @jilt-sebastian

    I am having the error in the following code snippet:
    boosted_cnn = AdaBoostClassifier(base_estimator= model(), n_estimators=20)
    boosted_audio.fit(X,Y)

    shape of X (a,100,1) and Y (a, b) where b is the number of classes and a is the number of examples
    fit gives be the following error:
    *** ValueError: Found array with dim 3. Estimator expected <= 2.

  24. chkoar commented on Mar 21, 2019

    @chkoar
    Contributor

    @jilt-sebastian This functionality hasn't released yet. You probably need to install scikit-learn from master.

  25. jnothman commented on Mar 21, 2019

    @jnothman
    MemberAuthor
  26. jilt-sebastian commented on Mar 21, 2019

    @jilt-sebastian

    Cool. Thank you

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

    EnhancementModeratehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions