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
TThe numeric data type used for calculations (e.g., float, double).
- Inheritance
-
RidgeClassifier<T>
- Implements
-
IClassifier<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:
- Convert class labels to numbers (-1 and +1 for binary)
- Fit a ridge regression to these numbers
- 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
optionsLinearClassifierOptions<T>Configuration options for the classifier.
regularizationIRegularization<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
Train(Matrix<T>, Vector<T>)
Trains the Ridge Classifier using closed-form solution.
public override void Train(Matrix<T> x, Vector<T> y)
Parameters
xMatrix<T>yVector<T>