Add option to pass a callback function to optimize()#79
Merged
HarrisonKramer merged 2 commits intomasterfrom Feb 22, 2025
Merged
Add option to pass a callback function to optimize()#79HarrisonKramer merged 2 commits intomasterfrom
optimize()#79HarrisonKramer merged 2 commits intomasterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## master #79 +/- ##
==========================================
- Coverage 96.57% 96.56% -0.02%
==========================================
Files 105 105
Lines 6340 6348 +8
==========================================
+ Hits 6123 6130 +7
- Misses 217 218 +1
|
HarrisonKramer
approved these changes
Feb 22, 2025
Owner
|
Looks good. Thanks for the contribution! And nice catch on updating to the best parameters after the optimization completes. I'll merge now. Regards, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This simple PR allows to pass a callback function to scipy's
optimize().This allows the user to add anything he likes to vizualize the optimization progress, for example (tested in a notebook):
Only
LeastSquaresdoesn't seem to accept a callback function.I also included a fix to update the lens at the end of the optimization with the best paramerters (
result.x), as the last merit function call is not necessarily the lowest one.Of course plotting during the optimization slows it significantly, but that's up to the user.
drpaprika