ProphetModel<T, TInput, TOutput>

Models & Types · AiDotNet.TimeSeries

Represents a Prophet model for time series forecasting.

Inheritance: TimeSeriesModelBase<T> → ProphetModel<T, TInput, TOutput>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

Think of the Prophet model as a smart crystal ball for predicting future values in a series of data points over time. It’s like predicting weather, but for any kind of data that changes over time, such as sales, website traffic, or stock prices. The model looks at past patterns, including seasonal changes (like how sales might increase during holidays) and overall trends, to make educated guesses about future values.

How It Works

The Prophet model is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects.

Example

var dateFeatures = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var futureDateFeatures = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var values = new Vector<double>(new double[] { 0.0, 1.0, 0.0, 1.0 });
// Create a Prophet-style model for time series with trend and seasonality
var options = new ProphetOptions<double, Matrix<double>, Vector<double>>();
var result = new AiModelBuilder<double, Matrix<double>, Vector<double>>()
    .ConfigureModel(new ProphetModel<double, Matrix<double>, Vector<double>>(options))
    .Build(dateFeatures, values);
Vector<double> forecast = result.Predict(futureDateFeatures);

Constructors

Constructor Summary
ProphetModel(ProphetOptions<T, TInput, TOutput> options) Initializes a new instance of the ProphetModel<T> class.

Properties

Property Summary
bool IsOptimized { get; set; } Gets whether parameter optimization succeeded during the most recent training run.

Methods

Method Summary
Dictionary<string, T> EvaluateModel(Matrix<T> xTest, Vector<T> yTest) Evaluates the performance of the Prophet model on a test dataset.
List<ValueTuple<int, T, T, T>> DetectAnomaliesDetailed(Matrix<T> x, Vector<T> y) Detects anomalies and returns detailed information about each detected anomaly.
ModelMetadata<T> GetModelMetadata() Gets metadata about the model, including its type, parameters, and configuration.
T GetAnomalyThreshold() Gets the current anomaly detection threshold.
T PredictSingle(Vector<T> input) Predicts a single value based on the input vector.
ValueTuple<Vector<T>, Vector<T>, Vector<T>> PredictWithIntervals(Matrix<T> x) Computes prediction intervals for future forecasts.
Vector<T> ComputeAnomalyScores(Matrix<T> x, Vector<T> y) Computes anomaly scores for each point in a time series.
Vector<T> Predict(Matrix<T> input) Predicts output values for the given input matrix.
bool[] DetectAnomalies(Matrix<T> x, Vector<T> y) Detects anomalies in a time series by comparing predictions to actual values.
void SetAnomalyThreshold(T threshold) Sets a custom anomaly detection threshold.