Challenge - 5 Problems
Spark Regression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Linear Regression Model Training in Spark
What will be the output type of the variable
model after running the following Spark ML code?Apache Spark
from pyspark.ml.regression import LinearRegression lr = LinearRegression(featuresCol='features', labelCol='label') model = lr.fit(training_data)
Attempts:
2 left
💡 Hint
The fit() method returns the trained model object, not predictions or raw data.
✗ Incorrect
The fit() method of LinearRegression returns a LinearRegressionModel object that contains the learned coefficients and intercept. Predictions require calling transform() on this model.
❓ Model Choice
intermediateChoosing the Correct Regression Model for Spark
You want to predict a continuous target variable using Spark ML. Which model should you choose?
Attempts:
2 left
💡 Hint
Regression models predict continuous values, classification models predict categories.
✗ Incorrect
LinearRegression is used for predicting continuous numeric values. LogisticRegression and DecisionTreeClassifier are for classification. KMeans is for clustering.
❓ Metrics
advancedEvaluating Regression Model Performance in Spark
After training a regression model in Spark, which metric is best to evaluate how close the predicted values are to the actual values?
Attempts:
2 left
💡 Hint
Regression metrics measure error between predicted and actual numeric values.
✗ Incorrect
RMSE measures the average magnitude of prediction errors in regression. Accuracy, AUC, and F1 Score are classification metrics.
🔧 Debug
advancedIdentifying the Error in Spark Regression Code
What error will the following Spark code raise?
Apache Spark
from pyspark.ml.regression import LinearRegression lr = LinearRegression(featuresCol='features', labelCol='label') model = lr.fit(data) predictions = model.transform('data')
Attempts:
2 left
💡 Hint
Check the argument type passed to transform().
✗ Incorrect
The transform() method expects a DataFrame, but a string 'data' is passed, causing a TypeError.
🧠 Conceptual
expertEffect of Regularization Parameter in Spark Linear Regression
In Spark's LinearRegression, what is the effect of increasing the regularization parameter
regParam?Attempts:
2 left
💡 Hint
Regularization adds a penalty to large coefficients to simplify the model.
✗ Incorrect
Increasing regParam adds stronger penalty on coefficients, reducing their size and complexity, which helps prevent overfitting.
