1. Learn
  2. /
  3. Courses
  4. /
  5. Feature Engineering with PySpark

Exercise

Evaluating & Comparing Algorithms

Now that we've created a new model with GBTRegressor its time to compare it against our baseline of RandomForestRegressor. To do this we will compare the predictions of both models to the actual data and calculate RMSE and R^2.

Instructions

100 XP
  • Import RegressionEvaluator from pyspark.ml.evaluation so it is available for use later.
  • Initialize RegressionEvaluator by setting labelCol to our actual data, SALESCLOSEPRICE and predictionCol to our predicted data, Prediction_Price
  • To calculate our metrics, call evaluate on evaluator with the prediction values preds and create a dictionary with key evaluator.metricName and value of rmse, do the same for the r2 metric.