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

How can i use AdaBoostClassifier using 'base_estimator' parameter? #750

Closed
pvachill opened this issue Aug 29, 2018 · 2 comments
Closed

How can i use AdaBoostClassifier using 'base_estimator' parameter? #750

pvachill opened this issue Aug 29, 2018 · 2 comments
Labels

Comments

@pvachill
Copy link

pvachill commented Aug 29, 2018

I tried to use AdaBoostClassifer and i succeded in the scenario that i dont use the 'base_estimator' parameter. But when i try to set 'base_estimator' it fails. I tried two ways:
1)
'sklearn.ensemble.AdaBoostClassifier': {
'base_estimator': {
'sklearn.naive_bayes.GaussianNB': {
}
}
},

Which leads to: RuntimeError: A pipeline has not yet been optimized. Please call fit() first.

2 and a half)
'sklearn.ensemble.AdaBoostClassifier': {
'base_estimator': ['sklearn.naive_bayes.GaussianNB'] or ['sklearn.naive_bayes.GaussianNB()']
}

Which both lead to: RuntimeError: There was an error in the TPOT optimization process. This could be because the data was not formatted properly, or because data for a regression problem was provided to the TPOTClassifier object. Please make sure you passed the data to TPOT correctly.

But if use AdaBoostClassifier with any parameter except base_estimator it runs properly.
'sklearn.ensemble.AdaBoostClassifier': {
'param1': [something],
'param2': [something else]
}

Thanks you,
Achilleas.

@weixuanfu
Copy link
Contributor

weixuanfu commented Aug 29, 2018

Thank you for reporting this issue here. I just posted a PR #751 to fix this issue and we will release a new version of TPOT soon with this fix. For now, there are two work-arounds:

  1. install the PR with fix via the command below. But it is noted that it is based on development branch.
pip install --upgrade --no-deps --force-reinstall git+https://github.com/weixuanfu/tpot.git@issue750
  1. add a useless parameter ('priors': [None] in the demo below) to bypass the bug.
# coding: utf-8
from tpot import TPOTClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split

digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target,
                                                    train_size=0.75, test_size=0.25)

tpot_config = {
                                                         
'sklearn.ensemble.AdaBoostClassifier': {
'base_estimator': {
'sklearn.naive_bayes.GaussianNB': {
'priors': [None]
}
}
}
}

tpot = TPOTClassifier(generations=5, population_size=20, verbosity=2,
                      config_dict=tpot_config)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))

@weixuanfu
Copy link
Contributor

This issue should be fixed in TPOT 0.9.4. Please feel free to reopen this issue if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants