NonLinearRegressionBase<T>
Base Classes · AiDotNet.Regression
Base class for non-linear regression algorithms that provides common functionality for training and prediction.
Implements: IFeatureAware, IGradientComputable<T, Matrix<T>, Vector<T>>, IModelShape, INonLinearRegression<T>
Known derived types: GaussianProcessRegression<T>, IsotonicRegression<T>, KNearestNeighborsRegression<T>, KernelRidgeRegression<T>, LocallyWeightedRegression<T>, MixedEffectsModel<T>, MultilayerPerceptronRegression<T>, NeuralNetworkRegression<T>, RadialBasisFunctionRegression<T>, SplineRegression<T>, SuperLearner<T>, SupportVectorRegression<T>, SymbolicRegression<T>
How It Works
This abstract class implements core functionality shared by different non-linear regression algorithms, including kernel functions, regularization, and model serialization/deserialization.
Non-linear regression models can capture complex relationships in data that linear models cannot represent. They typically use kernel functions to transform the input space into a higher-dimensional feature space where the relationship becomes linear.
For Beginners: Non-linear regression is used when your data doesn’t follow a straight line pattern. These models can capture curved or complex relationships between your input features and target values. Think of it like having a flexible curve that can bend and shape itself to fit your data points, rather than just a straight line.
Properties
| Property | Summary |
|---|---|
ILossFunction<T> DefaultLossFunction { get; } |
|
bool SupportsParameterInitialization { get; } |
|
long ParameterCount { get; } |
|
string[] FeatureNames { get; set; } |
Gets or sets the feature names. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetFeatureImportance() |
Gets the feature importance scores as a dictionary. |
DynamicShapeInfo GetDynamicShapeInfo() |
|
IEnumerable<int> GetActiveFeatureIndices() |
Gets the indices of features that are actively used by the model. |
IFullModel<T, Matrix<T>, Vector<T>> Clone() |
Creates a shallow copy of the model. |
IFullModel<T, Matrix<T>, Vector<T>> DeepCopy() |
Creates a deep copy of the model. |
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters) |
Creates a new model with the specified parameters. |
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the model. |
ModelOptions GetOptions() |
|
Vector<T> ComputeGradients(Matrix<T> input, Vector<T> target, ILossFunction<T> lossFunction) |
|
Vector<T> GetParameters() |
Gets the model parameters as a single vector. |
Vector<T> Predict(Matrix<T> input) |
Makes predictions for the given input data. |
Vector<T> SanitizeParameters(Vector<T> parameters) |
|
bool IsFeatureUsed(int featureIndex) |
Determines whether a specific feature is used by the model. |
byte[] Serialize() |
Gets the type of the model. |
int[] GetInputShape() |
|
int[] GetOutputShape() |
|
void ApplyGradients(Vector<T> gradients, T learningRate) |
|
void Deserialize(byte[] modelData) |
Deserializes the model from a byte array. |
void Dispose() |
|
void LoadModel(string filePath) |
|
void LoadState(Stream stream) |
Loads the model’s state from a stream. |
void SaveModel(string filePath) |
|
void SaveState(Stream stream) |
Saves the model’s current state to a stream. |
void SetActiveFeatureIndices(IEnumerable<int> featureIndices) |
Sets the active feature indices for this model. |
void SetParameters(Vector<T> parameters) |
Sets the parameters for this model. |
void Train(Matrix<T> x, Vector<T> y) |
Trains the non-linear regression model on the provided data. |