Table of Contents

Class RidgeClassifier<T>

Namespace
AiDotNet.Classification.Linear
Assembly
AiDotNet.dll

Ridge Classifier - converts regression to classification using regularized least squares.

public class RidgeClassifier<T> : LinearClassifierBase<T>, IProbabilisticClassifier<T>, IClassifier<T>, IFullModel<T, Matrix<T>, Vector<T>>, IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Matrix<T>, Vector<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>, IGradientComputable<T, Matrix<T>, Vector<T>>, IJitCompilable<T>

Type Parameters

T

The numeric data type used for calculations (e.g., float, double).

Inheritance
RidgeClassifier<T>
Implements
IFullModel<T, Matrix<T>, Vector<T>>
IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>
IParameterizable<T, Matrix<T>, Vector<T>>
ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>
IGradientComputable<T, Matrix<T>, Vector<T>>
Inherited Members
Extension Methods

Remarks

Ridge Classifier uses ridge regression (L2 regularized least squares) and then converts the continuous predictions to class labels.

For Beginners: Ridge Classifier treats classification as a regression problem:

How it works:

  1. Convert class labels to numbers (-1 and +1 for binary)
  2. Fit a ridge regression to these numbers
  3. For prediction, output whichever class the regression is closest to

Why use Ridge Classifier:

  • Very fast training (closed-form solution)
  • Works well when number of features is large
  • Stable due to regularization
  • Good baseline classifier

Trade-offs:

  • Doesn't optimize classification accuracy directly
  • May not work as well as logistic regression for probability estimates
  • Assumes linear relationship between features and class labels

Constructors

RidgeClassifier(LinearClassifierOptions<T>?, IRegularization<T, Matrix<T>, Vector<T>>?)

Initializes a new instance of the RidgeClassifier class.

public RidgeClassifier(LinearClassifierOptions<T>? options = null, IRegularization<T, Matrix<T>, Vector<T>>? regularization = null)

Parameters

options LinearClassifierOptions<T>

Configuration options for the classifier.

regularization IRegularization<T, Matrix<T>, Vector<T>>

Optional regularization strategy.

Methods

Clone()

Creates a clone of the classifier model.

public override IFullModel<T, Matrix<T>, Vector<T>> Clone()

Returns

IFullModel<T, Matrix<T>, Vector<T>>

A new instance of the model with the same parameters and options.

CreateNewInstance()

Creates a new instance of the same type as this classifier.

protected override IFullModel<T, Matrix<T>, Vector<T>> CreateNewInstance()

Returns

IFullModel<T, Matrix<T>, Vector<T>>

A new instance of the same classifier type.

GetModelType()

Returns the model type identifier for this classifier.

protected override ModelType GetModelType()

Returns

ModelType

Train(Matrix<T>, Vector<T>)

Trains the Ridge Classifier using closed-form solution.

public override void Train(Matrix<T> x, Vector<T> y)

Parameters

x Matrix<T>
y Vector<T>