'Does a Pipeline object store the score of the data it trained with?

I was wondering if a saved model in a Pipeline object contains the score of the data with which it has been trained. If so, how to get that score without having to put the data back in?



Solution 1:[1]

This depends on the model. Mostly, no. Also, you'd need to specify what exactly you mean by "score"; there are many metrics that might be saved somewhere.

kNN models store the training data in a private attribute _fit_X (source), so you could recreate a score from that (though you're not really saving much work here).

HistGradientBoosting models store an iteration-wise training and validation score (docs). GradientBoosting models similarly save loss functions at each iteration.

Cross-validation models like LogisticRegressionCV save the cross-validation scores for each hyperparameter value. Those are significantly different from a training score though.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ben Reiniger