-
Notifications
You must be signed in to change notification settings - Fork 98
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
add r-squared metric #252
base: main
Are you sure you want to change the base?
add r-squared metric #252
Conversation
Add r-squared metric to FOOOF and FOOOFGroup objects, and FOOOFGroup report plot. R-squared is adjusted for the number of parameters in the model, facilitating model comparison.
Hey @mwprestonjr - thanks, this looks great! Is it okay with you if I target this for the 2.0 release, which will have the breaking change of name and so on? Since this updates the set of attributes on our core objects, I think it makes sense to put this update there. If this sounds good to you, I'll review this PR here, then redirect it to the 2.0 branch, and merge it there to be part of that release. |
Yea that sounds great, thanks. |
fooof/objs/fit.py
Outdated
|
||
# compute adjusted r-squared | ||
n = len(self.power_spectrum) # number of data points | ||
k = len(self.peak_params_) * 3 + 2 # number of parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwprestonjr - just checking in here: the number of parameters here is computed as n_peaks * 3 (reflecting the 3 Gaussian params per Gaussian), and then + 2, presumably for aperiodic - but I think this should be +2 if fixed, +3 if knee mode, right? Or, more generally, n_params = n_peaks * n_params_per_peak + n_ap_param
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Tom, nice catch. Sorry I missed this. I've now made this update.
Hey @mwprestonjr - I'm keeping this in mind for integrating into 2.0, which I plan to include a somewhat broader framework for specifying and calculating goodness of fit measures. I left a quick comment above to make sure I understand. I'm still working on some re-organizations for 2.0 that will add the new fit measures, and this will need a bit of refactoring then - do you want me to tag you back in when this PR could be refactored into 2.0, or is it easier if I go ahead and adapt this PR into some of the updates directly? |
parameter count has been updated to take into account the aperiodic mode.
Hey @TomDonoghue, sorry for the late reply. It's likely easier for you to adapt this PR into some of your updates directly at this point. But let me know what you think. Happy to help |
R-squared metric added to FOOOF and FOOOFGroup objects, and FOOOFGroup report plot.
R-squared is adjusted for the number of parameters in the model, facilitating model comparison (#251).