Table of Contents

Class DataAggregationHelper

Namespace
AiDotNet.Helpers
Assembly
AiDotNet.dll

Helper class for aggregating data samples.

public static class DataAggregationHelper
Inheritance
DataAggregationHelper
Inherited Members

Remarks

DataAggregationHelper provides utility methods for combining multiple data samples (Matrix, Vector, or Tensor) into a single aggregated structure.

For Beginners: When loading data in batches or streaming, you often need to combine multiple smaller pieces into one larger structure. This helper provides optimized methods for this common operation.

Methods

Aggregate<T, TData>(List<TData>, string)

Aggregates a list of data samples into a single structure.

public static TData Aggregate<T, TData>(List<TData> items, string itemTypeName)

Parameters

items List<TData>

The list of items to aggregate.

itemTypeName string

The name used in error messages (e.g., "input" or "output").

Returns

TData

An aggregated structure containing all samples.

Type Parameters

T

The numeric type of the elements.

TData

The data type (Matrix, Vector, or Tensor).

Remarks

This method supports aggregation of Matrix<T>, Vector<T>, and Tensor<T> types. For matrices, rows are concatenated vertically. For vectors, elements are concatenated sequentially. For tensors, samples are concatenated along the first dimension.

Exceptions

InvalidOperationException

Thrown when the list is empty.

NotSupportedException

Thrown when the data type is not supported.