QuestionQ102

VerifiedModel Development

A data scientist developed a random forest regressor, rfr, and made it the final stage of a Spark MLPipeline pipeline. They then configured cross-validation with pipeline as the estimator in the following code block:

Question Image

What is a negative consequence of using pipeline as the estimator in the cross-validation process instead of using rfr as the estimator?

Explanation

A Spark Pipeline is an estimator whose stages run in sequence whenever it is fit: estimator stages are fit and the resulting models transform the data for later stages. Cross-validation fits the estimator for each fold and parameter map, so using the full pipeline repeats its fitting and transformation work, increasing runtime. Fitting preprocessing inside each training fold helps avoid validation-data leakage rather than causing it.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!