Login using Social Account
     Continue with GoogleLogin using your credentials
Let us now compute the model score on train data, validation data, and test data.
We shall use the model.evaluate()
and print the Mean Squared Error and Root Mean Squared Error for each of the train, validation and test sets.
Use the below function to compute the model performance.
import math
def model_score(model, X_train, y_train, X_val, y_val , X_test, y_test):
print('Train Score:')
train_score = model.evaluate(X_train, y_train, verbose=0)
print("MSE: {:.5f} , RMSE: {:.2f}".format(train_score[0], math.sqrt(train_score[0])))
print('Validation Score:')
val_score = model.evaluate(X_val, y_val, verbose=0)
print("MSE: {:.5f} , RMSE: {:.2f}".format (val_score[0], math.sqrt(val_score[0])))
print('Test Score:')
test_score = model.evaluate(X_test, y_test, verbose=0)
print("MSE: {:.5f} , RMSE: {:.2f}".format (test_score[0], math.sqrt(test_score[0])))
model_score(model, trainX, trainY ,valX, valY , testX, testY)
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...