Skip to content

Add tide forecasting example using NNS.ARMA - #49

Merged
OVVO-Financial merged 2 commits into
mainfrom
claude/upbeat-pascal-fq49g2
Jun 18, 2026
Merged

Add tide forecasting example using NNS.ARMA#49
OVVO-Financial merged 2 commits into
mainfrom
claude/upbeat-pascal-fq49g2

Conversation

@OVVO-Financial

Copy link
Copy Markdown
Owner

Summary

This PR adds a complete gist demonstrating tide forecasting using the ovvo-nns library's NNS.ARMA algorithm. The example reproduces Lord Kelvin's 1872 tide prediction machine results but discovers seasonal patterns empirically from raw water-level data rather than relying on hand-tuned astronomical constituents.

Changes

  • tides_nns.py: Main forecasting script that:

    • Loads NOAA tide-gauge data from a remote CSV
    • Splits data into training (pre-2019-07-15) and test (2-week holdout) sets
    • Uses nns_seas() to detect seasonal periods from the training data
    • Filters periods to only those usable by the optimizer (< training_set / 4)
    • Runs nns_arma_optim() to fit an ARMA model with seasonal factors
    • Evaluates forecast accuracy (R² ≈ 0.965) and generates visualization
    • Includes timing instrumentation for performance tracking
  • README.md: Documentation covering:

    • Historical context of Lord Kelvin's tide machine (1872)
    • Overview of the NNS.ARMA approach vs. physics-based methods
    • Results summary with selected periods and R² metric
    • Installation and execution instructions
    • Explanation of the non-obvious period filtering logic
  • tides_forecast.png: Generated visualization showing actual vs. predicted tides with 95% prediction intervals

Notable Implementation Details

  • Period filtering is applied before slicing to top-100 candidates, ensuring the optimizer receives usable periods rather than oversized ones that would be rejected
  • Uses lin_only=True for linear-only optimization
  • Validation window equals the forecast horizon (2 weeks) for realistic out-of-sample evaluation
  • Runtime dominated by optimizer (~2 min); seasonality detection is near-instant

https://claude.ai/code/session_01MxVLKYqazC2uuAW3P3MbAm

claude added 2 commits June 18, 2026 14:15
Self-contained example reproducing Lord Kelvin's tide forecast from the raw
water-level series using NNS.ARMA (R^2 ~ 0.965 out-of-sample). Includes the
script, a README with historical framing, and the generated figure.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxVLKYqazC2uuAW3P3MbAm
Use an f-string instead of percent formatting and group the first-party
nns import so the example passes the repo's ruff check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxVLKYqazC2uuAW3P3MbAm
@OVVO-Financial
OVVO-Financial merged commit 10fdd4c into main Jun 18, 2026
8 checks passed
@OVVO-Financial
OVVO-Financial deleted the claude/upbeat-pascal-fq49g2 branch June 18, 2026 14:35
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.

2 participants