Business API

Anomaly detection, what-if analysis, backtesting, and business metrics.

AnomalyDetector

AnomalyDetector()

Methods

  • detect(data, method="auto", threshold=3.0)AnomalyResult

AnomalyResult

AttributeTypeDescription
.indicesnp.ndarrayAnomaly indices
.scoresnp.ndarrayAnomaly scores
.methodstrMethod used
.nAnomaliesintCount
.anomalyRatiofloatRatio

Methods: auto, zscore, iqr, rolling

WhatIfAnalyzer

WhatIfAnalyzer()

Methods

  • analyze(basePredictions, historicalData, scenarios, period=7) → list of ScenarioResult
  • compareSummary(results)str

Scenario Parameters

ParameterTypeDescription
namestrScenario label
trend_changefloatTrend adjustment
seasonal_multiplierfloatScale seasonality
shock_atintShock step index
shock_magnitudefloatShock size
shock_durationintShock length
level_shiftfloatPermanent level change

Backtester

Backtester(nFolds=5, horizon=30, strategy='expanding', minTrainSize=50)

Methods

  • run(y, modelFactory)BacktestResult
    • y: Full time series (ndarray)
    • modelFactory: Zero-argument callable that returns a model with .fit(y) and .predict(steps) methods

BacktestResult

AttributeTypeDescription
.avgMAPEfloatAverage MAPE
.avgRMSEfloatAverage RMSE
.foldslistPer-fold results
.bestFoldintBest fold number
.worstFoldintWorst fold number

BusinessMetrics

BusinessMetrics()

Methods

  • calculate(actual, predicted)dict

Returns: bias, biasPercent, trackingSignal, wape, mase, overForecastRatio, underForecastRatio, fillRateImpact, forecastAccuracy