Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Machine Learning for Finance in Python

Cursus bekijken

Oefeninstructies

  • 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().

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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()
Code bewerken en uitvoeren