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

Add random_state parameter to stacking cv estimators #523

Merged
merged 5 commits into from
Apr 29, 2019

Conversation

qiagu
Copy link
Contributor

@qiagu qiagu commented Apr 29, 2019

Description

The idea just came to my mind today. Since the latest check_cv from scikit-learn supports random_state, stacking CV estimators can have the parameter now.

Related issues or pull requests

Pull Request Checklist

  • Added a note about the modification or contribution to the ./docs/sources/CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./mlxtend/*/tests directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under mlxtend/docs/sources/ (if applicable)
  • Ran nosetests ./mlxtend -sv and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., nosetests ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv)
  • Checked for style issues by running flake8 ./mlxtend

@coveralls
Copy link

coveralls commented Apr 29, 2019

Coverage Status

Coverage decreased (-0.001%) to 91.546% when pulling 34ddf02 on qiagu:stacking into c338a1f on rasbt:master.

@rasbt
Copy link
Owner

rasbt commented Apr 29, 2019

Great point. I think this is a relatively new feature and I didn't know it would work. While this is certainly great, one little request though,

random_state : int, RandomState instance or None, optional (default: 0)
     Constrols the randomness of the cv splitter. Used when `cv` is
     integer and `shuffle=True`. New in v0.16.0.

Can we change that to None as default setting (while I personally prefer setting random seeds explicitly, I think this is a scikit-learn default to use None.)

@@ -115,7 +115,7 @@ class StackingCVRegressor(_BaseXComposition, RegressorMixin, TransformerMixin):
def __init__(self, regressors, meta_regressor, cv=5,
shuffle=True, random_state=0, verbose=0,
refit=True, use_features_in_secondary=False,
store_train_meta_features=False, n_jobs=1,
store_train_meta_features=False, n_jobs=None,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually meant the random_state to be random_state=None, but good that you caught the n_jobs=None thing as well (which is another sklearn convention)

@qiagu
Copy link
Contributor Author

qiagu commented Apr 29, 2019

The random_state default was given by not None because the shuffle was True and also it may save typing in many cases. I'm fine with None and don't have strong inclinations. I'll follow your decision. @rasbt

@rasbt
Copy link
Owner

rasbt commented Apr 29, 2019

I see. I think shuffle=True would still work with random_state=None -- as far as I know, random_state=None will just use the default random seed. I don't have a strong preference, but for consistency with sklearn, maybe random_state=None is the slightly better choice.

@qiagu
Copy link
Contributor Author

qiagu commented Apr 29, 2019

I agree. Updated.

@rasbt
Copy link
Owner

rasbt commented Apr 29, 2019

That's great, happy to merge this. Thanks a lot!

@rasbt rasbt merged commit ec2658c into rasbt:master Apr 29, 2019
@qiagu qiagu deleted the stacking branch November 24, 2019 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants