Home > Software design >  How many learnable parameters has a ridge regression classifier that has 20 inputs and 3 classes?
How many learnable parameters has a ridge regression classifier that has 20 inputs and 3 classes?

Time:07-05

How many learnable parameters has a ridge regression classifier (this one: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.RidgeClassifierCV.html) if it is trained with input data that has a dimension of 20 (i.e. 20 features / attributes) and 3 classes / labels?

CodePudding user response:

By looking at RidgeClassifierCV, we can see that there is two type of learnable parameters:

  • coef_: ndarray of shape (n_targets, n_features)
  • intercept_ : ndarray of shape (n_targets,).

Therefore a dataset with 20 features and 3 classes will have 3*20 3 = 63 learnable parameters.

The code below can be used to compute the number of parameters of RidgeClassifierCV.

As follows:

from sklearn.datasets import make_classification
from sklearn.linear_model import RidgeClassifierCV

X, y = make_classification(n_samples=10000, n_features=20, n_classes=3, n_informative=10)
model = RidgeClassifierCV().fit(X, y)

n_params = model.coef_.size   model.intercept_.size 
  • Related