Skip to content

Linear PSM: optional expected sign for season selection - #23

Open
nickmckay wants to merge 1 commit into
mainfrom
season-sign
Open

nickmckay wants to merge 1 commit into
mainfrom
season-sign

Conversation

@nickmckay

Copy link
Copy Markdown

Closes #17.

Linear.calibrate(). A new expected_sign argument (1 or -1) restricts the season search to seasons whose slope has that sign. If no season has it, the PSM is left uncalibrated, as when no season has enough overlapping data.

calib_psms(). A new pid_sign_dict argument passes the expected sign per record (for example, from the direction in each record's interpretation metadata) to records with the Linear PSM. Records not in the dictionary, and other PSMs, are unconstrained.

The default behavior is unchanged.

Use in Presto. We currently do this after calibration in our own workflow. In Presto2k it changes the season of 74 records and drops 48 that have no season with the expected sign.

Tests. Three new tests use a synthetic record that responds positively to Jan to Jun and more strongly, negatively, to Jul to Dec. Without a constraint, Jul to Dec is chosen. With expected_sign=1, Jan to Jun is chosen. With no matching season, the PSM isn't calibrated. The full suite passes (220 tests).

Not covered. Bilinear has no equivalent yet.

Note. This and the R floor PR both add an argument to calib_psms(), so whichever is merged second will need a small conflict resolved.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TsdL1gpFWoD4LYexEPr6LD

calibrate() picks the season with the best score (adjusted R2 by
default) whatever the sign of the slope, so a season with a negative
temperature response can win for a record whose metadata says it
responds positively. expected_sign (1 or -1) restricts the choice to
seasons whose slope has that sign, and leaves the record uncalibrated if
none does; calib_psms passes it per record through pid_sign_dict.
Default behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsdL1gpFWoD4LYexEPr6LD
Copilot AI balanced review requested due to automatic review settings October 22, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

Season selection ignores the sign of the response

2 participants