CCDM<T>

Models & Types · AiDotNet.Finance.Forecasting.Foundation

CCDM — Channel-aware Contrastive Conditional Diffusion for multivariate probabilistic time series forecasting (Li, Chen and Xiong, 2024).

Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → ForecastingModelBase<T> → TimeSeriesFoundationModelBase<T> → CCDM<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

CCDM generates future values the way image generators create pictures: it starts from random noise and removes it step by step, guided by the history. Every run starts from different noise, so it draws many possible futures; the median is the forecast and the spread tells you how uncertain it is. With several series it lets them inform each other through attention across the series.

How It Works

A DDPM forecaster (paper Section 3, following the authors’ reference implementation at github.com/LSY-Cython/CCDM). The denoiser treats every variable as a token: the past window and the noisy future of each variable are embedded independently by channel-independent dense modules, concatenated, mixed across variables by channel-wise diffusion transformers whose norms the diffusion step modulates (adaLN-Zero), and decoded back to the horizon as a noise estimate. Training minimizes the noise-prediction error (Equation 1), optionally plus the denoising-based InfoNCE term (Equation 6); forecasting runs ancestral DDPM sampling for NumSamples paths and reports their per-position median, with quantiles taken from the same paths.

Windows are normalized per variable by the context’s mean and standard deviation; the target is normalized with the same statistics for training and the sampled forecast is mapped back.

Example

var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputSize: 168, outputSize: 24);
            
var model = new CCDM<double>(architecture);
var history = Tensor<double>.CreateRandom(new[] { 1, 168 });          // the last 168 observations
var forecast = model.Forecast(history);                                  // median of 100 paths
var bands = model.Forecast(history, quantiles: new[] { 0.1, 0.5, 0.9 }); // [1, horizon, 3]

Constructors

Constructor Summary
CCDM(NeuralNetworkArchitecture<T> architecture, CCDMOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)
CCDM(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, CCDMOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)

Properties

Property Summary
FoundationModelSize ModelSize { get; }
bool IsChannelIndependent { get; }
bool SupportsTraining { get; }
bool UseNativeMode { get; }
int MaxContextLength { get; }
int MaxPredictionHorizon { get; }
int NumFeatures { get; }
int PatchSize { get; }
int PredictionHorizon { get; }
int SequenceLength { get; }
int Stride { get; }

Methods

Method Summary
Dictionary<string, T> Evaluate(Tensor<T> predictions, Tensor<T> actuals)
Dictionary<string, T> GetFinancialMetrics()
ModelMetadata<T> GetModelMetadata()
Tensor<T> ApplyInstanceNormalization(Tensor<T> input) Per-variable window normalization (the reference instance_normalization): each variable of the context is centred and scaled by its own mean and standard deviation over time.
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps)
Tensor<T> ForwardForTraining(Tensor<T> input) Tape-aware forward over the denoiser at the last diffusion step, with fixed noise.