Time-Series Forecasting App
Table of Contents
Project Overview
A workbench-first time-series forecasting, temporal data mining, and Gemma 4 / Gemini 4 AI platform. Built to benchmark how classical and ensemble ML algorithms learn temporal patterns across four synthetic regimes (Periodic, Noisy, Trending, and Irregular), user-uploaded datasets (CSV/JSON/ARFF/PDF), and live Open-Meteo city telemetry, it pairs 3D phase-space attractor visualization and residual error plots with side-by-side run comparison and an Ask AI drawer.
Problem Statement
Real-world temporal signals frequently exhibit non-stationarity, stochastic noise, and abrupt structural shocks that violate naive autoregressive continuity assumptions. Decomposing an empirical signal into its constituent temporal drivers:
Standard machine learning pipelines often suffer from catastrophic data leakage when random shuffling corrupts chronological causality, or choke under the latency demands of real-time streaming feature extraction. Building a dependable forecasting workbench requires sub-50ms concurrent feature extraction, strict out-of-sample chronological evaluation, and multi-model uncertainty estimation combining classical algorithms with generative AI reasoning.
Solution Architecture
The platform employs a decoupled, multi-runtime architecture: Next.js 15 App Router renders the reactive client workbench and 3D phase-space canvas, a Node.js 22 server manages persistent WebSocket telemetry streaming and PostgreSQL storage with automatic zero-config fallback, and a concurrent Go engine executes high-throughput feature extraction and bootstrap confidence calculations.
x(t), y(t), z(t)). Drag to orbit the manifold or switch regimes to inspect trajectory stability.
Technical Deep Dives
Concurrent Go ML Engine & Bootstrap Uncertainty Bounds
- Engineered a dedicated Go microservice (
go-signal-engine) that transforms raw time series into normalized feature matrices using concurrent goroutines. - Extracts multi-step lag variables (
lag_1throughlag_10), rolling statistics (mean, variance, min, max, EWMAα = 0.3), momentum, and temporal autocorrelation spectra. - Trains four distinct forecasters: Naive Baseline (
ŷt = yt−1), L2 Ridge Linear Regression, Random Forest (25 bootstrapped decision trees with feature subsampling), and Gradient Boosting (35 additive stagewise trees). - Computes 200-iteration residual bootstrap distributions to establish non-parametric 95% confidence intervals, providing realistic uncertainty intervals without assuming Gaussian error normality.
Strict Chronological Splitting & Zero Data Leakage
- Enforces rigorous temporal partitioning: the earliest 70% of observations form the Training set, the subsequent 15% serve as Validation, and the final 15% are held out as the unseen Out-of-Sample Test set.
- Fit-transform isolation:
StandardScalerparameters (μ, σ) are calculated strictly on the training partition and applied forward to validation and test partitions, preventing future lookahead leakage. - Evaluates models using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and Mean Absolute Percentage Error (MAPE) against pure out-of-sample observations.
Real-Time WebSocket Telemetry & 3D Phase-Space Attractors
- Maintains a persistent full-duplex WebSocket gateway (
/ws/signals) streaming 1.2-second live signal ticks, step predictions, and anomaly alerts. - Implements delay coordinate embedding in three dimensions (
t, yt−1, yt) using an interactive Canvas/WebGL viewer to reveal hidden limit cycles, chaotic strange attractors, and noise-induced orbital degradation. - Detects structural shocks and transient spikes using dynamic Z-score thresholds (
|Z| > 2.35σ) and stationarity variance-ratio tests.
Gemma 4 & Gemini 4 AI Co-Pilot, Live Feeds & Run Diffing
- Integrates Google DeepMind
gemma-4-31b-itandgemini-4-argonvia the official@google/genaiSDK Interactions API (client.interactions.create), leveraging strict JSON schema formatting with explicit Live API vs. Fallback status indicators. - Powers an interactive Ask AI slide-over drawer alongside regime classification, model trade-off justifications, and 5-step-ahead forecasts with 95% confidence bounds.
- Includes a zero-key Open-Meteo live telemetry connector (7 days of hourly temperature, solar irradiance, wind speed, and humidity), residual error subplots, side-by-side Run History & Diff comparison, and CSV/JSON export.
- Dual-engine execution: Includes a deterministic TypeScript parity engine alongside the Go worker, enabling zero-config instant startup and CI test runs without requiring local Docker or Go installations.
Algorithm & Complexity Benchmarks
Rolling Feature Extraction
vs O(N·W) naive recomputeO(N) Space: O(W) Single-pass EWMA and rolling moments across 10 lag steps.
200-Iter Residual Bootstrap CI
vs O(B · N) single-threadO(B · N / P) Space: O(B) Parallelized across P Go goroutines for sub-45ms non-parametric bounds.
Architecture Trade-Offs
Concurrent Feature & Bootstrap Engine
Goroutines execute lag-matrix extraction and 200-iteration residual bootstrap resampling in <45ms with predictable low memory overhead, avoiding GIL bottlenecks.
Zero-Config Local Persistence
Preserves full SQL relational schemas in production while booting instantly in-memory during CI or local evaluation without external credentials.
Project Results
Sub-50ms Latency
Go compute engine executes signal synthesis, feature extraction, 4 model fits, and 200 bootstrap iterations in under 45ms.
Zero Leakage Guarantee
Strict chronological partitioning ensures genuine out-of-sample validation across all evaluation metrics.
Resilient Dual Engine
Zero-configuration fallback to in-memory PostgreSQL (pg-mem) and TypeScript engine allows complete local development without external service dependencies.