Getting Started

Tutorial: Building with CleaveDB

Forecasting (FORECAST) — Overview

In conventional data stacks, computing statistical predictions and time-series projections requires exporting raw tables into external Python scripts or analytical warehouses. CleaveDB integrates Feature 29: Statistical Prediction (FORECAST) directly into its query engine, enabling in-database machine learning and trend extrapolation with zero data movement.

Supported Prediction Methods

1. METHOD LINEAR

Computes Ordinary Least Squares (OLS) linear regression via vector math. Fits a best-fit trendline, calculates the R² coefficient of determination, and extrapolates values across future periods.

2. METHOD MOVING_AVERAGE

Smooths short-term fluctuations and noisy time series by computing rolling mean projections across a customizable window frame (WINDOW <n>, default 3).

3. METHOD EXPONENTIAL

Applies single exponential smoothing with a decay coefficient (α = 0.5), placing greater weight on recent observations while dampening historical variance.

4. Flexible Time Horizons

Project forward across granular units including DAYS, HOURS, MINUTES, and SECONDS, with built-in security caps up to 10,000 steps.

General Syntax

Every forecast statement follows a structured declarative pattern:

FORECAST <bucket> PREDICT <value_field> OVER <time_field> NEXT <horizon> <time_unit> METHOD <method> [WINDOW <window>]

Explore Forecasting Guides

Select a guide below to master time-series extrapolation in CleaveDB: