You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Minimize validation of X in ensembles with a base estimator #7768
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.
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.
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 ?
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?
Thanks for looking into this. Not all ensembles are meta-estimators. Here
we intend things that should be generic enough to support non-scikit-learn
use-cases: not just dealing with rectangular feature matrices.
On Fri, 14 Sep 2018 at 08:23, Karthik Duddu ***@***.***> wrote:
As a first step, I tried looking at 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 <https://github.com/jnothman> @amueller
<https://github.com/amueller> considering this, should this be a WONTFIX,
or should all the meta-estimators be fixed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7768 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz68Axs1khuYjm7lM4guYgyf2IlUL_ks5uatrDgaJpZM4KiQ_P>
.
@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.
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.
Activity
chkoar commentedon Oct 31, 2016
That could be applied to any meta-estimator that uses a base estimator, right?
jnothman commentedon Nov 1, 2016
Yes, it could be. I didn't have time when I wrote this issue to check the applicability to other ensembles.
[-]Minimize validation of X in AdaBoost[/-][+]Minimize validation of X in ensembles with a base estimator[/+]jnothman commentedon Nov 1, 2016
Updated title and description
chkoar commentedon Nov 1, 2016
@jnothman I think that we have two options.
check_inputinfit,predict, etc with default vauleTruein order to preserve the current behavior. Thecheck_inputcould be in the constrcutor.What do you think? I'll sent a PR.
jnothman commentedon Nov 1, 2016
IMO assuming the base estimator manages validation is fine.
Chaitya62 commentedon Dec 1, 2016
Is this still open ? can I work on it?
chkoar commentedon Dec 1, 2016
@Chaitya62 I didn't have the time to work on this. So, go ahead.
Chaitya62 commentedon Dec 1, 2016
@chkoar onit!
Chaitya62 commentedon Dec 4, 2016
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 ?
jnothman commentedon Dec 4, 2016
Chaitya62 commentedon Dec 4, 2016
Cool I ll submit a PR soon
4 remaining items
dalmia commentedon Feb 1, 2017
@Chaitya62 Thanks!
gokart23 commentedon Sep 13, 2018
I'd like to work on this, if that's ok
gokart23 commentedon Sep 13, 2018
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 :
@jnothman @amueller considering this, should this be a WONTFIX, or should all the meta-estimators be fixed?
jnothman commentedon Sep 15, 2018
chkoar commentedon Feb 14, 2019
@jnothman
Adaboosttests are testing the sparsity of theX. This means that we should skip these tests in order to relax the validation, right?jnothman commentedon Feb 14, 2019
jilt-sebastian commentedon Mar 21, 2019
@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.
jnothman commentedon Mar 21, 2019
Please give code that shows the error you encounter
jilt-sebastian commentedon Mar 21, 2019
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.
chkoar commentedon Mar 21, 2019
@jilt-sebastian This functionality hasn't released yet. You probably need to install
scikit-learnfrom master.jnothman commentedon Mar 21, 2019
jilt-sebastian commentedon Mar 21, 2019
Cool. Thank you