TimeGPT<T>
Models & Types · AiDotNet.Finance.Forecasting.Foundation
TimeGPT-style time series foundation model implementation.
Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → ForecastingModelBase<T> → TimeGPT<T>
For Beginners
TimeGPT brings GPT-like capabilities to time series:
The Key Insight: Just as GPT was trained on internet-scale text data to become a general-purpose language model, TimeGPT is trained on millions of diverse time series to become a general-purpose forecasting model.
Core Features:
- Large-scale Pre-training: Trained on millions of time series
- Zero-shot Forecasting: No training needed for new data
- Uncertainty Quantification: Provides prediction intervals
- Multi-horizon: Forecasts at any horizon
Advantages:
- Works out-of-the-box on new time series
- No hyperparameter tuning required
- Handles various frequencies and domains
- Production-ready forecasting
How It Works
TimeGPT represents a GPT-style architecture adapted for time series forecasting, featuring large-scale pre-training on diverse time series data with zero-shot and few-shot forecasting capabilities.
Reference: Garza et al., “TimeGPT-1”, 2023.
https://arxiv.org/abs/2310.03589
Example
// Create a TimeGPT-style foundation model for zero-shot time series forecasting
// Pre-trained on millions of diverse time series for out-of-the-box predictions
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputHeight: 512, inputWidth: 1, inputDepth: 1, outputSize: 24);
// Training mode with GPT-style autoregressive generation
var model = new TimeGPT<double>(architecture);
// ONNX inference mode with pre-trained model
var onnxModel = new TimeGPT<double>(architecture, "timegpt.onnx");
Constructors
| Constructor | Summary |
|---|---|
TimeGPT(NeuralNetworkArchitecture<T> architecture, TimeGPTOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Initializes a new instance in native mode for training or fine-tuning. |
TimeGPT(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, TimeGPTOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Initializes a new instance using an ONNX pretrained model. |
Properties
| Property | Summary |
|---|---|
bool IsChannelIndependent { get; } |
|
bool SupportsTraining { get; } |
|
bool UseConformalPrediction { get; } |
Gets whether conformal prediction is used for uncertainty. |
bool UseNativeMode { get; } |
|
double ConfidenceLevel { get; } |
Gets the confidence level for prediction intervals. |
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() |
|
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input) |
|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> ApplyInstanceNormalization(Tensor<T> input) |
|
Tensor<T> AutoregressiveForecast(Tensor<T> input, int steps) |
|
void CalibrateConformalPrediction(List<Tensor<T>> historicalData, List<Tensor<T>> actuals) |
Calibrates the model using historical data for conformal prediction. |
void FineTune(List<Tensor<T>> trainingData, List<Tensor<T>> targets) |
Fine-tunes the model on domain-specific data. |