MulaiMulai sekarang secara gratis

Evaluate the regression tree

In this exercise, you will evaluate the test set performance of dt using the Root Mean Squared Error (RMSE) metric. The RMSE of a model measures, on average, how much the model's predictions differ from the actual labels. The RMSE of a model can be obtained by computing the square root of the model's Mean Squared Error (MSE).

The features matrix X_test, the array y_test, as well as the decision tree regressor dt that you trained in the previous exercise are available in your workspace.

Latihan ini adalah bagian dari kursus

Machine Learning with Tree-Based Models in Python

Lihat Kursus

Petunjuk latihan

  • Import the function mean_squared_error as MSE from sklearn.metrics.
  • Predict the test set labels and assign the output to y_pred.
  • Compute the test set MSE by calling MSE and assign the result to mse_dt.
  • Compute the test set RMSE and assign it to rmse_dt.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import mean_squared_error from sklearn.metrics as MSE
from ____.____ import ____ as ____

# Compute y_pred
____ = ____.____(____)

# Compute mse_dt
____ = ____(____, ____)

# Compute rmse_dt
____ = ____

# Print rmse_dt
print("Test set RMSE of dt: {:.2f}".format(rmse_dt))
Edit dan Jalankan Kode