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

Adding GroupKFold and testing it #200

Merged
merged 8 commits into from Oct 20, 2023
Merged

Conversation

hyun-seo
Copy link
Contributor

Referring to #157, there is an issue about group cross-validation.

This pull request implementation this issue by adding new argument kfolds_group and
using sklearn.model_selection.GroupKFold.

@hyun-seo hyun-seo marked this pull request as ready for review September 21, 2023 05:48
Copy link
Contributor

@mandjevant mandjevant left a comment

Choose a reason for hiding this comment

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

Requesting these initial changes for it to go through the automated testing.
Once it gets through, Ill take a closer look

hpsklearn/estimator/_cost_fn.py Outdated Show resolved Hide resolved
hpsklearn/estimator/_cost_fn.py Outdated Show resolved Hide resolved
hpsklearn/estimator/_cost_fn.py Outdated Show resolved Hide resolved
hpsklearn/estimator/estimator.py Outdated Show resolved Hide resolved
hpsklearn/estimator/estimator.py Outdated Show resolved Hide resolved
hpsklearn/estimator/estimator.py Outdated Show resolved Hide resolved
tests/test_estimator/test_estimator.py Outdated Show resolved Hide resolved
tests/test_estimator/test_estimator.py Show resolved Hide resolved
tests/test_estimator/test_estimator.py Show resolved Hide resolved
Thank you for your review. I applied all the suggestions.

Co-authored-by: mandjevant <38689620+mandjevant@users.noreply.github.com>
apply the review

Co-authored-by: mandjevant <38689620+mandjevant@users.noreply.github.com>
@mandjevant mandjevant self-requested a review October 5, 2023 07:56
@hyun-seo
Copy link
Contributor Author

hyun-seo commented Oct 6, 2023

@mandjevant
Thank you so much for taking the time to review my pr.
This is my first attempt at contributing to open source and I had a lot of issues, but I think I learned a lot from your kind help.
I have one question: what is the exact meaning of # noqa: E226 in the testcode? Why is this phrase needed in the test?

@mandjevant
Copy link
Contributor

@mandjevant Thank you so much for taking the time to review my pr. This is my first attempt at contributing to open source and I had a lot of issues, but I think I learned a lot from your kind help. I have one question: what is the exact meaning of # noqa: E226 in the testcode? Why is this phrase needed in the test?

Thank you for your contribution!
The reason your PR did not go through automated testing was because of flake8 style guide enforcement. In most lines, flake was correct and notified us of style issues that we resolved. But in that one line, I deemed that flake8 was wrong.
It threw an inconsistency with rule E226 which, when enforced, would make the line unreadable.

Thus, I suppressed the rule on (only) that line by adding a comment stating noqa: E226.

Copy link
Contributor

@mandjevant mandjevant left a comment

Choose a reason for hiding this comment

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

In addition, please change

n_folds: int, default is None
            When n_folds is not None, use K-fold cross-validation when
            n_folds > 2. Or, use leave-one-out cross-validation when
            n_folds = -1.

to

n_folds: int, default is None
            When n_folds is not None, use K-fold cross-validation when
            n_folds > 2. Or, use leave-one-out cross-validation when
            n_folds = -1. For Group K-fold cross-validation, functions as
            `n_splits`.

In both places:

https://github.com/hyperopt/hyperopt-sklearn/blob/9938225c7d4dd85fbc45be12aa2f74cdde527ad6/hpsklearn/estimator/estimator.py#L244C30-L244C30

https://github.com/hyun-seo/hyperopt-sklearn/blob/9938225c7d4dd85fbc45be12aa2f74cdde527ad6/hpsklearn/estimator/_cost_fn.py#L60C26-L60C26

Function and test case look appropriate

hpsklearn/estimator/estimator.py Show resolved Hide resolved
tests/test_estimator/test_estimator.py Outdated Show resolved Hide resolved
@mandjevant mandjevant self-requested a review October 9, 2023 09:32
Copy link
Contributor

@mandjevant mandjevant left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for your contribution!
@bjkomer Any thoughts?

@mandjevant
Copy link
Contributor

Ill go ahead and merge this. Thank you for your contribution @hyun-seo

@mandjevant mandjevant merged commit 840cfc9 into hyperopt:master Oct 20, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants