QuestionQ98

VerifiedUsing Spark ML

A Data Scientist is creating a machine-learning pipeline to classify raw text with a Logistic Regression model in Spark, using Spark MLlib Pipelines. The pipeline contains three stages: a Tokenizer (to split raw text into tokens), a HashingTF (to convert tokens into hashes), and Logistic Regression itself (to classify the texts). The Spark DataFrame containing training data is named trainingDF, and the one containing test data is named testDF.

To accomplish this, they use the following incomplete code:

Question Image

Which option correctly identifies:

(i) The full command to train the model;

(ii) The full command to run prediction on the test data;

(iii) The type of the model object returned by the model-training command.

Explanation

A Spark Pipeline is an Estimator, so calling fit(trainingDF) trains its estimator stages and returns a fitted PipelineModel. A PipelineModel is a Transformer, so transform(testDF) applies the fitted tokenization, feature hashing, and logistic-regression stages to the test DataFrame, producing prediction output.

Learn more

Community Discussion

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