CommencerCommencer gratuitement

See how the ensemble performed

Let's check performance of our ensembled model to see how it's doing. We should see roughly an average of the R\(^2\) scores, as well as a scatter plot that is a mix of our previous models' predictions. The bow-tie shape from the custom loss function model should still be a bit visible, but the edges near x=0 should be softer.

Cet exercice fait partie du cours

Machine Learning for Finance in Python

Afficher le cours

Instructions

  • Evaluate the R\(^2\) scores on the train and test sets. Use the sklearn r2_score() function (already imported for you) with train_targets and train_preds from the previous exercise.
  • Plot the train and test predictions versus the actual values with plt.scatter().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

from sklearn.metrics import r2_score

# Evaluate the R^2 scores
print(r2_score(____, ____))
print(r2_score(test_targets, test_preds))

# Scatter the predictions vs actual -- this one is interesting!
plt.scatter(____, ____, ____)
plt.scatter(test_preds, test_targets, label='test')
plt.legend(); plt.show()
Modifier et exécuter le code