Skip to main content

Forecasting

Soltix provides built-in time-series forecasting with 7 algorithms (6 statistical + 1 auto-selector) in Go, plus optional ML models via the soltix-ml Python service.

Built-in Forecasters (Go)

AlgorithmTypeBest For
smaSimple Moving AverageStable, flat data
exponentialExponential SmoothingData with noise
linearLinear RegressionData with clear trend
holt_wintersTriple Exponential SmoothingSeasonal + trend data
arimaARIMA(p,d,q)Stationary or differenced data
prophetProphet-style decompositionComplex seasonality (daily/weekly/yearly)
autoAuto-selectorGeneral use

Auto-Selection Logic

ConditionSelected Algorithm
Has seasonality + enough dataHolt-Winters
Has trendLinear
≥20 data pointsExponential
Small datasetSMA

API

Endpoints

MethodPath
GET/v1/databases/:db/collections/:col/forecast
POST/v1/databases/:db/collections/:col/forecast

Parameters

ParameterDefaultDescription
device_idDevice IDs (required)
start_timeRFC3339 — historical data start (required)
end_timeRFC3339 — historical data end (required)
fieldSingle field to forecast
fieldsMultiple fields (POST body)
algorithmautosma, exponential, holt_winters, linear, arima, prophet, auto, ml
horizon24Number of periods to forecast
seasonal_period24For Holt-Winters
data_interval1hData interval: 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
ml_algorithmWhen algorithm=ml: random_forest or lstm

Example

# Auto forecast for next 24 hours
curl "http://localhost:5555/v1/databases/mydb/collections/sensors/forecast?\
device_id=sensor-001&\
field=temperature&\
start_time=2026-01-01T00:00:00Z&\
end_time=2026-01-15T00:00:00Z&\
horizon=24&\
algorithm=auto" \
-H "X-API-Key: your-api-key"

Response

{
"results": [
{
"device_id": "sensor-001",
"field": "temperature",
"predictions": [
{
"timestamp": "2026-01-15T01:00:00Z",
"value": 25.8,
"lower_bound": 24.2,
"upper_bound": 27.4
}
],
"model_info": {
"algorithm": "holt_winters",
"mape": 3.2,
"mae": 0.8,
"rmse": 1.1,
"data_points": 336
}
}
]
}

ML Models (soltix-ml)

For heavier-weight predictions, the optional soltix-ml Python service trains machine learning models:

ModelAlgorithmDescription
Random Forestscikit-learn RFEnsemble method, warm start, sliding window features
LSTMPyTorch LSTMNeural network with normalization baked into ONNX graph

Training Pipeline

  1. Discovery: Connect to Router → list databases, collections, devices
  2. Data: Load 30 days of CSV data per device
  3. Features: Sliding window of configurable size
  4. Training: Both RF and LSTM for every device × field
  5. Export: ONNX format (input: (1, window_size) float32, output: (1, 1) float32)
  6. Upload: Multipart form upload to Router

Using ML Forecasts

curl "http://localhost:5555/v1/databases/mydb/collections/sensors/forecast?\
device_id=sensor-001&\
field=temperature&\
algorithm=ml&\
ml_algorithm=lstm&\
horizon=24" \
-H "X-API-Key: your-api-key"