# Taking advantage of Eras

**URL:** <https://forum.numer.ai/t/taking-advantage-of-eras/3269>\
**Category:** Data Science\
**Created:** [May 11, 2021, 1:31am UTC](https://forum.numer.ai/t/taking-advantage-of-eras/3269 "2021-05-11T01:31:09Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ml\_is\_lyf](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@ml\_is\_lyf](https://forum.numer.ai/u/ml_is_lyf)\
**Post date:** [May 13, 2021, 5:58pm UTC](https://forum.numer.ai/t/taking-advantage-of-eras/3269/3 "2021-05-13T17:58:35Z")

</div>

> [@ryendu](#):
>
> `loss = F.mse(y_pred,y_real)`

This is where you can get some performance gains with some improvements. We’re evaluated on our correlation, so why not use correlation in your loss function. Take a look at this post for some tips:

> [@Custom loss functions for XGBoost using PyTorch](http://forum.numer.ai/t/custom-loss-functions-for-xgboost-using-pytorch/960):
>
> Here is some code showing how you can use PyTorch to create custom objective functions for XGBoost. Objective functions for XGBoost must return a gradient and the diagonal of the Hessian (i.e. matrix of second derivatives). Internally XGBoost uses the Hessian diagonal to [rescale the gradient](https://stats.stackexchange.com/questions/202858/xgboost-loss-function-approximation-with-taylor-expansion). The Hessian is very expensive to compute, so we replace it with all ones. This basically forces XGBoost to do standard gradient descent rather than the fancier second order version it usually uses. It works…

In my experience, you still want to include MSE. But theoretically and practically there are merits to including in your loss function the thing we’re evaluated on

Then it becomes clear why you want them ordered by era, as correlation doesn’t make much sense unless you’re looking at an era (tbf trying correlation with random samples could be interesting, but I don’t think it has as good theoretical merits)

You can also train different models on differents eras and then ensemble them

There are actually lots of things you can do with eras, thankfully a lot of helpful have shared their ideas in Arbitrage’s office hours, so make sure to go watch all of them:

> **[Numerai](https://www.youtube.com/c/Numerai/videos)**
>
> An artificial intelligence hedge fund built by a community of anonymous data scientists

Also Arbitrage has some good suggestions about how to use eras in his intro video series:

![](https://canada1.discourse-cdn.com/flex009/uploads/numerai/optimized/2X/0/07c72b3c0c148113f508d433a08aef5fc0fb709d_2_690x388.jpeg)https://www.youtube.com/embed/8Heck3JAyAw?feature=oembed&wmode=opaque&list=PLz3D6SeXhT3v39noGoGEDFMfhZsa1P9Qz

---

_[View the full topic](https://forum.numer.ai/t/taking-advantage-of-eras/3269)._
