Table of Contents

Interface IRegularization<T, TInput, TOutput>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll
public interface IRegularization<T, TInput, TOutput>

Type Parameters

T
TInput
TOutput

Methods

GetOptions()

Retrieves the current regularization options.

RegularizationOptions GetOptions()

Returns

RegularizationOptions

The regularization options currently in use.

Remarks

This method returns the configuration settings for the regularization technique.

For Beginners: This method lets you check what regularization settings are being used. The options typically include:

  • The type of regularization (L1, L2, Elastic Net, etc.)
  • The strength of regularization (how much to penalize complex models)
  • Other specific settings for the chosen regularization method

Regularize(Matrix<T>)

Applies regularization to a matrix of input features.

Matrix<T> Regularize(Matrix<T> data)

Parameters

data Matrix<T>

The input matrix to regularize.

Returns

Matrix<T>

The regularized matrix.

Remarks

This method applies regularization to a matrix of input features.

For Beginners: This method helps prevent overfitting by modifying your input data according to the regularization strategy. It can reduce the influence of extreme values or unnecessary features.

This is typically used when preparing data for model training.

Regularize(Vector<T>)

Applies regularization to output data or model coefficients.

Vector<T> Regularize(Vector<T> data)

Parameters

data Vector<T>

The output data or coefficients to regularize.

Returns

Vector<T>

The regularized data or coefficients.

Remarks

This method applies regularization to output data or model coefficients.

For Beginners: Model coefficients are the "importance weights" your model assigns to different features. This method helps keep these weights from getting too large, which can cause overfitting.

For example:

  • With L1 regularization, some coefficients might be reduced to exactly zero
  • With L2 regularization, all coefficients are typically reduced but remain non-zero

Think of it as encouraging your model to use simpler explanations by penalizing complex solutions.

Regularize(TOutput, TOutput)

Applies regularization to the gradient during optimization.

TOutput Regularize(TOutput gradient, TOutput coefficients)

Parameters

gradient TOutput

The original gradient vector from the optimization algorithm.

coefficients TOutput

The current coefficient values.

Returns

TOutput

The regularized gradient vector.

Remarks

This method modifies the gradient used in optimization algorithms to account for regularization.

For Beginners: When a model is learning (training), it follows a "gradient" that tells it which direction to adjust its parameters to improve. This method modifies that gradient to include the regularization constraints.

It's like adding a gentle force that pulls the model toward simpler solutions during training. This helps prevent the model from becoming too complex and overfitting the training data.