feat: summary() returns dict of stats along with printing and added validation tests #315#504
Open
archi3103 wants to merge 1 commit intodswah:mainfrom
Open
feat: summary() returns dict of stats along with printing and added validation tests #315#504archi3103 wants to merge 1 commit intodswah:mainfrom
archi3103 wants to merge 1 commit intodswah:mainfrom
Conversation
953ffaa to
6467da4
Compare
6467da4 to
4c09a49
Compare
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.
Fixes #315
This PR addresses the issue by modifying the
summary()method to return a dictionary containing model and term statistics.Changes
summary()to create and returnstats_dict.pygam/tests/test_summary_return.pyto make sure the dictionary is returning the right numbers from the model.Why this is a good modification
Currently, the
summary()method only prints information to the console. But if someone wants to use values like the AIC or p-values in a loop to compare a bunch of different models, they have to copy the numbers by hand.By having the function return a dictionary, it's much easier to work with the data in code or save it for later. I also made sure to keep the full numbers (not just the rounded ones in the table) so they stay accurate for calculations.
No changes to current functionality
I was careful to make sure this doesn't break anything for existing users. The table still prints in the console exactly as it did before.
If someone doesn't want or needs the dictionary, they can just call
gam.summary()like they always have. In Python, if you don't assign the output of a function to a variable, the return value is just ignored, so it won't affect their workflow or clutter their terminal. This makes the change purely additive.Testing