-
Notifications
You must be signed in to change notification settings - Fork 857
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
Support fit_params for cross_val_score in StackingClassifier #177
Comments
Hi @agzamovr ,
Oh yes, of course :). I have an example here: http://rasbt.github.io/mlxtend/user_guide/classifier/StackingClassifier/#example-3-stacked-classification-and-gridsearch The syntax for accessing estimator params is similar to the one used by from sklearn.pipeline import make_pipeline
from sklearn.model_selection import GridSearchCV
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
pipe = make_pipeline(StandardScaler(), LogisticRegression())
params = {'logisticregression__C': [0.1, 1., 10.]}
grid = GridSearchCV(estimator=pipe,
param_grid=params,
cv=5)
grid.fit(X, y) (Essentially, it is just lowercasing the class name. If you have multiple objects from the same class, it would enumerate them, e.g., 'logisticregression-1', 'logisticregression-2', etc. So, looking at your code above, it looks like you have a small typo, and it should be fit_params = {
'xgbclassifier__eval_metric': 'mlogloss',
... PS: If in doubt what the actual parameter names are, you could get a list via estimator = StackingClassifier(classifiers=[clf1, clf2],
meta_classifier=lr)
estimator.get_params().keys() Let me know if it solves the problem! |
Thank you for response! |
Oh I see what you mean now. I don't know how I could have misread your issue so badly :P. Yeah, unfortunately, this doesn't work, yet. But I guess it shouldn't be too hard to add this features; it could be pretty useful imho |
Hi @rasbt , I've encountered a problem when using GridSearchCV and cross_val_score. |
Is it possible to pass fit params for individual classifiers? I tried to pass fit params for XGBClassifier but got error. My code is following:
The text was updated successfully, but these errors were encountered: