M4DatasetLoader<T>

Models & Types ยท AiDotNet.Data.TimeSeries

Loads time series datasets from the M4 Competition for benchmarking forecasting models.

Inheritance: DataLoaderBase<T> โ†’ M4DatasetLoader<T>

For Beginners

The M4 Competition is the gold standard for evaluating time series forecasting models.

What is M4?

  • A collection of 100,000 real-world time series
  • Multiple frequencies: Yearly, Quarterly, Monthly, Weekly, Daily, Hourly
  • Standardized train/test splits for fair comparison
  • Established benchmark metrics (SMAPE, MASE, OWA)

Why M4 matters:

  • Industry standard: Used by researchers and practitioners worldwide
  • Diverse data: Business, economic, demographic, and financial series
  • Published baselines: Compare your model against known benchmarks
  • Academic recognition: Results published in major forecasting journals

M4 Dataset Statistics:

Frequency Series Count Forecast Horizon Typical History
Yearly 23,000 6 13-835 years
Quarterly 24,000 8 16-866 quarters
Monthly 48,000 18 42-2794 months
Weekly 359 13 80-2597 weeks
Daily 4,227 14 93-9919 days
Hourly 414 48 700-960 hours

How It Works

The M4 Competition (Makridakis Competitions) is a highly influential forecasting competition that provides 100,000 time series across multiple frequencies for benchmarking forecasting methods.

Constructors

Constructor Summary
M4DatasetLoader(M4Frequency frequency, int batchSize, string dataPath, bool autoDownload) Initializes a new instance of the M4DatasetLoader class.

Properties

Property Summary
IReadOnlyList<M4TimeSeries<T>> TestSeries { get; } Gets the test time series data (ground truth for evaluation).
IReadOnlyList<M4TimeSeries<T>> TrainingSeries { get; } Gets the training time series data.
M4Frequency Frequency { get; } Gets the frequency of the loaded time series.
int ForecastHorizon { get; } Gets the forecast horizon for this frequency.
int SeriesCount { get; } Gets the number of time series in the dataset.
int TotalCount { get; }
string Description { get; }
string Name { get; }

Methods

Method Summary
List<M4TimeSeries<T>> GetNextBatch() Gets the next batch of time series for iteration.
T CalculateMASE(IReadOnlyList<T> forecast, IReadOnlyList<T> actual, IReadOnlyList<T> trainingData, int seasonalPeriod) Calculates the Mean Absolute Scaled Error (MASE) for M4 evaluation.
T CalculateSMAPE(IReadOnlyList<T> forecast, IReadOnlyList<T> actual) Calculates the Symmetric Mean Absolute Percentage Error (SMAPE) for M4 evaluation.
ValueTuple<M4TimeSeries<T>, M4TimeSeries<T>> GetSeries(int index) Gets a specific time series by index.