Skip to main content
The FugueBackend class enables distributed computation for StatsForecast using Fugue, which provides a unified interface for Spark, Dask, and Ray backends without requiring code rewrites.

Overview

With FugueBackend, you can:
  • Distribute forecasting and cross-validation across clusters
  • Switch between Spark, Dask, and Ray without changing your code
  • Scale to large datasets with parallel processing
  • Maintain the same API as the standard StatsForecast interface

API Reference

FugueBackend

Bases: ParallelBackend FugueBackend for Distributed Computation. Source code. This class uses Fugue backend capable of distributing computation on Spark, Dask and Ray without any rewrites. Parameters:

FugueBackend.forecast

Memory Efficient core.StatsForecast predictions with FugueBackend. This method uses Fugue’s transform function, in combination with core.StatsForecast’s forecast to efficiently fit a list of StatsForecast models. Parameters: Returns:

FugueBackend.cross_validation

Temporal Cross-Validation with core.StatsForecast and FugueBackend. This method uses Fugue’s transform function, in combination with core.StatsForecast’s cross-validation to efficiently fit a list of StatsForecast models through multiple training windows, in either chained or rolled manner. StatsForecast.models’ speed along with Fugue’s distributed computation allow to overcome this evaluation technique high computational costs. Temporal cross-validation provides better model’s generalization measurements by increasing the test’s length and diversity. Parameters: Returns:

Quick Start

Basic Usage with Spark

Basic Forecasting

Dask Distributed Example

Here’s a complete example using Dask for distributed predictions:

Distributed Forecast

The FugueBackend automatically handles distributed forecasting when you pass a Dask/Spark/Ray DataFrame:

Distributed Cross-Validation

Perform distributed temporal cross-validation across your cluster:

How It Works

  1. Automatic Detection: When you pass a Spark, Dask, or Ray DataFrame to StatsForecast methods, the FugueBackend is automatically used.
  2. Data Partitioning: Data is partitioned by unique_id, allowing parallel processing across different time series.
  3. Distributed Execution: Each partition is processed independently using the standard StatsForecast logic.
  4. Result Aggregation: Results are collected and returned in the same format as the input (Spark/Dask/Ray DataFrame).

Supported Backends

  • Apache Spark: For large-scale distributed processing
  • Dask: For flexible distributed computing with Python
  • Ray: For modern distributed machine learning workloads

Notes

  • Ensure your cluster has sufficient resources for the number of time series and models
  • The unique_id column should be string type for distributed operations
  • Use .compute() on Dask DataFrames to materialize results
  • Use .show() or .collect() on Spark DataFrames to view results

See Also