AutoMLEnsembleModel<T>
Models & Types ยท AiDotNet.AutoML
A simple tabular ensemble model used as a facade-safe AutoML final model.
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> โ AutoMLEnsembleModel<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
Instead of trusting one model, an ensemble uses multiple models and combines their answers. This often improves stability and accuracy.
How It Works
This ensemble combines multiple IFullModel members by averaging (regression/binary)
or voting (multi-class) over their predictions.
Example
var features = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var targets = new Vector<double>(new double[] { 3.1, 7.2, 11.0, 15.1 });
// Any IFullModel over the same input and output types can join the ensemble.
var models = new List<IFullModel<double, Matrix<double>, Vector<double>>>
{
new SimpleRegression<double>(),
new SimpleRegression<double>(),
new SimpleRegression<double>()
};
var result = new AiModelBuilder<double, Matrix<double>, Vector<double>>()
.ConfigureModel(new AutoMLEnsembleModel<double>(models, PredictionType.Regression))
.Build(features, targets);
var testData = new Matrix<double>(new double[,] { { 9.0, 10.0 } });
Vector<double> predictions = result.Predict(testData);
Constructors
| Constructor | Summary |
|---|---|
AutoMLEnsembleModel() |
Initializes a new instance of the AutoMLEnsembleModel class. |
AutoMLEnsembleModel(IEnumerable<IFullModel<T, Matrix<T>, Vector<T>>> members, PredictionType predictionType, IReadOnlyList<double> weights) |
Properties
| Property | Summary |
|---|---|
ILossFunction<T> DefaultLossFunction { get; } |
|
IReadOnlyList<IFullModel<T, Matrix<T>, Vector<T>>> Members { get; } |
Gets the member models in the ensemble. |
PredictionType PredictionType { get; set; } |
Gets or sets the prediction type used to combine outputs (regression vs classification). |
double[] Weights { get; set; } |
Gets or sets the per-member weights used when combining predictions. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetFeatureImportance() |
|
IEnumerable<int> GetActiveFeatureIndices() |
|
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters) |
|
ModelMetadata<T> GetModelMetadata() |
|
Vector<T> ComputeGradients(Matrix<T> input, Vector<T> target, ILossFunction<T> lossFunction) |
|
Vector<T> Predict(Matrix<T> input) |
|
bool IsFeatureUsed(int featureIndex) |
|
void ApplyGradients(Vector<T> gradients, T learningRate) |
|
void LoadModel(string filePath) |
|
void LoadState(Stream stream) |
|
void SaveModel(string filePath) |
|
void SaveState(Stream stream) |
|
void SetActiveFeatureIndices(IEnumerable<int> featureIndices) |
|
void Train(Matrix<T> input, Vector<T> expectedOutput) |