adding parameter for counterfactual method #1128
Open
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
This pull request introduces a new method parameter to the counterfactual() function in mlxtend.evaluate.counterfactual, allowing users to specify the optimization algorithm used by scipy.optimize.minimize. Previously, the method was hardcoded to 'Nelder-Mead', which limited flexibility in choosing solvers that may perform better for different problem types.
By default, the method remains 'Nelder-Mead' to preserve backward compatibility. Users can now pass other valid methods like 'Powell', 'CG', or 'BFGS' for experimentation or improved convergence.
Related issues or pull requests
Fixes #1029
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
I'm a beginner and this is one of my first contributions to an open-source project. I’ve tried to follow the contribution guidelines carefully, but I’d really appreciate any feedback, suggestions, or guidance to improve. Thank you for the opportunity!