InMemoryDataLoader<T, TInput, TOutput>
Models & Types · AiDotNet.Data.Loaders
A simple in-memory data loader for supervised learning data.
Inheritance: DataLoaderBase<T> → InputOutputDataLoaderBase<T, TInput, TOutput> → InMemoryDataLoader<T, TInput, TOutput>
For Beginners
This is the easiest data loader to use. Simply pass your feature data (X) and label data (Y) to the constructor, and you’re ready to train!
Example:
// Create feature matrix and label vector
var features = new Matrix<double>(100, 5); // 100 samples, 5 features
var labels = new Vector<double>(100); // 100 labels
// Create the loader
var loader = new InMemoryDataLoader<double, Matrix<double>, Vector<double>>(features, labels);
// Use with AiModelBuilder
var builder = new AiModelBuilder<double, Matrix<double>, Vector<double>>();
var model = new SimpleRegression<double>();
var result = await builder
.ConfigureDataLoader(loader)
.ConfigureModel(model)
.BuildAsync();
How It Works
InMemoryDataLoader is the simplest way to create a data loader from existing data. It’s ideal for:
- Small to medium datasets that fit in memory
- Quick prototyping and testing
- Converting raw arrays or matrices to the IDataLoader interface
Constructors
| Constructor | Summary |
|---|---|
InMemoryDataLoader(TInput features, TOutput labels) |
Creates a new in-memory data loader with the specified features and labels. |
Properties
| Property | Summary |
|---|---|
int FeatureCount { get; } |
|
int OutputDimension { get; } |
|
int TotalCount { get; } |
|
string Description { get; } |
|
string Name { get; } |
Methods
| Method | Summary |
|---|---|
ValueTuple<IInputOutputDataLoader<T, TInput, TOutput>, IInputOutputDataLoader<T, TInput, TOutput>, IInputOutputDataLoader<T, TInput, TOutput>> Split(double trainRatio, double validationRatio, int? seed) |