Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Code of Conduct
Description
Permutation tests (
mlxtend.evaluate.permutation.py
) should return as p-value the proportion of permutations for which the calculated statistic is at least as extreme as the one observed in the experiment. (See in particular reference [3] of Wikipedia p-value page).The current code only takes into account more extreme values.
In cases of approximation running a series of permutations but not all, it is also common to include the actual experiment as one additional permutation, avoiding the possible p-value of 0 and also closer to the exact p-value when the number of rounds is close to the number of possible combinations, as explained in detail in this paper:
The function could raise a warning if the user wants to run a number of simulations that is close (> 50% ?) to the total number of possible combinations, so that they can switch to the exact method in that case. I have not implemented this here but I could if it is found useful.
Finally, I ran across a test failure in
mlxtend.feature_extraction.test_principal_analysis.py
wheretest_variance_explained_ratio
expects a float to be exactly1.
where on my machine it was1.0000000000000002
.Fixed with
assert_almost_equal
.Related issues or pull requests
Fixes #718
Pull Request Checklist
./docs/sources/CHANGELOG.md
file (if applicable)./mlxtend/*/tests
directories (if applicable)mlxtend/docs/sources/
(if applicable)PYTHONPATH='.' pytest ./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.,PYTHONPATH='.' pytest ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv
)flake8 ./mlxtend