Home > Software design >  GridSearchCV VS CV of the model
GridSearchCV VS CV of the model

Time:11-19

What is the difference between using RidgeClassifierCV and tuning the model after training it

classifier = RidgeClassifierCV(alphas=np.logspace(-3, 3, 10), normalize=True)
classifier.fit(X_train, y_train)

AND

param_grid = {'alphas': np.logspace(-3, 3, 10)}
grid = GridSearchCV(RidgeClassifier(),param_grid, refit = True)

CodePudding user response:

RidgeClassifierCV allows you to perform cross validation and find the best alpha with respect to your dataset.

GridSearchCV allows you not only to finetune an estimator but the preprocessing steps of a Pipeline as well.

From the documentation, The advantage of an EstimatorCV such as RidgeClassifierCV is that they can take advantage of warm-starting by reusing precomputed results in the previous steps of the cross-validation process. This generally leads to speed improvements.

As a conclusion if you are only trying to finetune a ridge classifier, RidgeClassifierCV should be the best choice as it might be faster. However if you are having extra preprocessing steps, it should be better to use GridSearchCV.

  • Related