Skip to content

Replace pyGAM with TweedieRegressor in MachineLearningSetup - #329

Merged
RHammond2 merged 13 commits into
NatLabRockies:developfrom
RHammond2:enhancement/replace-pygam
Oct 30, 2026
Merged

RHammond2 merged 13 commits into
NatLabRockies:developfrom
RHammond2:enhancement/replace-pygam

Conversation

@RHammond2

Copy link
Copy Markdown
Collaborator

This PR replaces the pyGAM GAM usage in MachineLearningSetup with scikit-learn's TweedieRegressor to account for pyGAM's incompatibility with the scikit-learn ML pipeline tools. Because the TweedieRegressor does not perform well on the power curve generation workflow, pyGAM will continue to be used in that context where there is no scikit-learn infrastructure.

To account for the performance differences, the TweedieRegressor's default hyperparameter settings are configured to sample from multiple distributions, learning rates, and use a higher max_iter to converge on a better solution. To further account for the fact that Gamma distributions cannot handle non-positive values, the MonteCarloAEP manually overrides the hyper parameter distribution setting when negative values are detected in the filtered energy generation column.

It was also found that the n_splines input to GAM was no longer creating different fits as n_splines now must be defined on a per-term basis, not a general model input.

On the whole these changes have a minor impact on the AEP results, but allow for newer versions of scikit-learn to be installed that are no longer set at a maximum Python of 3.13.

@RHammond2 RHammond2 added enhancement maintenance Issues related to code maintainence. E.g., upgrading versions of dependencies, fixing the CI pipelie analysis-methods Relating to analysis methods. utilities Relating to anything in utils/ labels Oct 27, 2026
@RHammond2 RHammond2 added the on hold Something that, for a variety of reasons, might not be addressed in the short term. label Oct 28, 2026
@RHammond2

Copy link
Copy Markdown
Collaborator Author

Placing this on hold until the root of the wake loss discrepancies can be resolved.

@RHammond2 RHammond2 removed the on hold Something that, for a variety of reasons, might not be addressed in the short term. label Oct 30, 2026
@RHammond2
RHammond2 merged commit 8b355c8 into NatLabRockies:develop Oct 30, 2026
10 checks passed
@RHammond2
RHammond2 deleted the enhancement/replace-pygam branch October 30, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analysis-methods Relating to analysis methods. enhancement maintenance Issues related to code maintainence. E.g., upgrading versions of dependencies, fixing the CI pipelie utilities Relating to anything in utils/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant