Skip to content

Conversation

@brhooper
Copy link
Contributor

@brhooper brhooper commented Jan 29, 2026

Addresses https://github.com/metoppv/mo-blue-team/issues/1051

This PR adds the capability to use constant extrapolation to the GAMPredict class and the relevant SAMOS classes and CLIs.

When extrapolating along a single term in a GAM, the default behaviour is to extend the trend of that term when predicting for input values which are outside the bounds of the training data. When using constant extrapolation, this will instead treat any values outside of the training range as equal to the smallest/largest value in the training range, as required.

For example, suppose our fitted GAM term were a simple linear term y = x + 2 trained on x values in the range [0, 10]. Predictions from this term would look as below, using the two different extrapolation approaches:

Default extrapolation Constant extrapolation
x 2 2
y 4 4
Default extrapolation Constant extrapolation
x -1 -1
y 1 2
Default extrapolation Constant extrapolation
x 100 100
y 102 12

Testing:

  • Ran tests and they passed OK
  • Added new tests for the new feature(s)

@brhooper brhooper force-pushed the mobt1051_gam_extrapolation branch from 937a454 to 3e6e226 Compare January 29, 2026 15:05
@bayliffe bayliffe self-assigned this Jan 30, 2026
Copy link
Contributor

@bayliffe bayliffe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything passes and I cannot see any issues with this. Good work.

@bayliffe bayliffe removed their assignment Jan 30, 2026
@gavinevans gavinevans self-assigned this Jan 30, 2026
Copy link
Contributor

@gavinevans gavinevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brhooper 👍

I think these changes are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants