QuestionQ118

VerifiedModel Development

A machine learning engineer wants to build a Spark ML linear regression model to predict a hotel room’s price. They use the Spark DataFrame train_df to train the model.

The Spark DataFrame train_df has the following schema:

Question Image

The machine learning engineer provides this code block:

Question Image

Which change, if any, must the machine learning engineer make to complete the task?

Explanation

Spark ML linear regression expects a vector-valued features column and a numeric label column. The features field already has Spark’s UDT vector type, while price is a DOUBLE; configuring featuresCol="features" and labelCol="price" and calling fit(train_df) is sufficient. transform is applied to a fitted model when producing predictions, and a Pipeline is not required for this estimator. Apache Spark LinearRegression documentation

Learn more

Community Discussion

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