Environment:Sktime Pytorch forecasting Cpflows MQF2 Dependencies
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Probabilistic_Forecasting |
| Last Updated | 2026-02-08 08:00 GMT |
Overview
Optional dependency providing cpflows for MQF2 (Multivariate Quantile Function Forecaster) distribution loss, enabling normalizing flow-based multivariate quantile estimation.
Description
This environment adds the `cpflows` package, which implements Deep Convex Flows and Sequential Flows used by the MQF2DistributionLoss metric. The cpflows dependency is loaded via `_safe_import`, which returns a mock object if the package is not installed, allowing the rest of the library to function without it. Multiple models declare cpflows as a soft dependency through the class tag system (`python_dependencies: ["cpflows"]`), which the test framework uses to skip relevant tests when the package is missing.
Usage
Required when using MQF2DistributionLoss as the loss function for any model (TFT, DeepAR, N-HiTS, DecoderMLP). Not needed for standard point losses (MAE, RMSE) or other distribution losses (Normal, NegativeBinomial). Install via `pip install pytorch-forecasting[mqf2]`.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, or Windows | No platform-specific restrictions |
| Hardware | Same as core | No additional hardware requirements |
| Python | >= 3.10 | Same as core package |
Dependencies
Python Packages
- `cpflows` (no version constraint specified)
Credentials
No credentials are required.
Quick Install
# Install with mqf2 extras
pip install pytorch-forecasting[mqf2]
# Or install individually
pip install cpflows
Code Evidence
Safe import pattern from `metrics/_mqf2_utils.py:5,15-16`:
from skbase.utils.dependencies import _safe_import
DeepConvexFlow = _safe_import("cpflows.flows.DeepConvexFlow")
SequentialFlow = _safe_import("cpflows.flows.SequentialFlow")
Class tag declaration from `models/deepar/_deepar_pkg.py:20` (also in TFT, N-HiTS, MLP pkgs):
"python_dependencies": ["cpflows"],
Test skip condition from `tests/test_metrics.py:414-416`:
@pytest.mark.skipif(
not _check_soft_dependencies("cpflows", severity="none"),
reason="cpflows not installed",
)
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `MQF2DistributionLoss` returns mock objects | cpflows not installed, _safe_import returned placeholder | `pip install cpflows` |
| Tests skipped for MQF2 | cpflows not in environment | Install via `pip install pytorch-forecasting[mqf2]` |
Compatibility Notes
- All platforms: cpflows is a pure Python package with no platform-specific restrictions.
- Models affected: TFT, DeepAR, N-HiTS, DecoderMLP all declare cpflows as a soft dependency for MQF2 loss support.