# Forecasting energy consumption: NWRMSE

**URL:** <https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173>\
**Category:** Power Laws\
**Created:** [March 11, 2018, 10:00pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173 "2018-03-11T22:00:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [March 11, 2018, 10:00pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/1 "2018-03-11T22:00:15Z")

</div>

Is there a reference implementation of the NWRMSE metric? Or does someone have one that they know works?

Thanks.

---

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [March 12, 2018, 11:03pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/2 "2018-03-12T23:03:09Z")

</div>

Would love to have more clarity here. I note the problem statement talks about a weight applied to entries to compute a weighted root mean squared error (WRMSE). However the formula in the next paragraph then shows that weight being applied to compute a root sum squared error (i.e. there is no mean applied). Either way I try things my numbers don’t seem to come out suitably. Would love to see some code.

Thanks.

---

<div class="post-metadata">

**Author:** ![LastRocky](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@LastRocky](https://community.drivendata.org/u/LastRocky)\
**Post date:** [March 12, 2018, 11:58pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/3 "2018-03-12T23:58:29Z")

</div>

The implementation of NWRMSE is very up to your train-validation splitting strategy, for example if you do random splitting for the training dataset, then there is no meaning to evaluate the NWRMSE, because it only makes sense when the data you evaluate is mostly continuous in timestamp, which is because you need to assign weight for each instance record beforehand. I have tried splitting the training dataset into 5 subparts based on datetime from the beginning of the timestamp to the end and used one subpart as validation dataset to evaluate the NWRMSE of the training and validation losses during training. But this kind of splitting strategy didn’t help too much compared to random splitting. Hope it helps.

---

<div class="post-metadata">

**Author:** ![bull](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.drivendata.org/bull/32/8_2.png) [@bull](https://community.drivendata.org/u/bull)\
**Post date:** [March 13, 2018, 5:50pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/4 "2018-03-13T17:50:13Z")

</div>

@mlean @LastRocky There is now an example implementation in pure numpy (no pandas) here:

> <https://github.com/drivendataorg/metrics/blob/master/metrics.py#L230-L284>

---

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [March 13, 2018, 9:31pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/5 "2018-03-13T21:31:49Z")

</div>

Thanks - really helpful. That’s clarified things and corrected my code. The weights are interesting. You assume a maximum length of 200 and then truncate the weights?

In the problem description page I’d list the RMSE weights as \frac{(600-2t+1)}{2_200}. The full WRMSE expression then has this weight term \frac{(600-2t+1)}{2_200\*T\_n}. It’s also important that the mean is over all sites and forecast periods (my original reading was that one took a mean over forecasts for a site and then a mean over sites).

Sadly I’m still not getting close to the leaderboard score (the leaderboard score is two orders of magnitude better) but I’m hoping that’s just my issue.

---

<div class="post-metadata">

**Author:** ![amogil](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.drivendata.org/amogil/32/635_2.png) [@amogil](https://community.drivendata.org/u/amogil)\
**Post date:** [March 13, 2018, 10:19pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/6 "2018-03-13T22:19:53Z")

</div>

> [@mlearn](#):
>
> (the leaderboard score is two orders of magnitude better) but I’m hoping that’s just my issue.

You are not alone :-/

---

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [March 14, 2018, 9:39am UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/7 "2018-03-14T09:39:48Z")

</div>

> [@amogil](#):
>
> > [@mlearn](#):
> >
> > (the leaderboard score is two orders of magnitude better) but I’m hoping that’s just my issue.
> 
> You are not alone :-/

Oh - it makes me both happy and sad to hear I’m not alone. Can we get some confirmation of the python scoring matching the leaderboard scoring? I’d hope the organisers can run the script offline against a few submissions.

---

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [March 16, 2018, 7:20pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/8 "2018-03-16T19:20:51Z")

</div>

Any progress on this? Can this be a fair competition if the evaluation metric is in doubt? The idea that my submission is getting what’s crudely a relative error of 0.2% is unlikely. We need to know what is being measured.

Also similar to another post about one of the related competitions - what is the public/private leaderboard split?

---

<div class="post-metadata">

**Author:** ![bull](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.drivendata.org/bull/32/8_2.png) [@bull](https://community.drivendata.org/u/bull)\
**Post date:** [March 19, 2018, 9:35pm UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/9 "2018-03-19T21:35:30Z")

</div>

We’ve made clarifications to the metric as announced here. This is just confirmation that the available implementation matches mathematically the scores on the platform. To calculate this consistently, competitors can treat T\_n as a constant of 200.

[https://www.drivendata.org/competitions/51/electricity-prediction-machine-learning/announcements/](https://www.drivendata.org/competitions/51/electricity-prediction-machine-learning/announcements/)

---

<div class="post-metadata">

**Author:** ![mlearn](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mlearn](https://community.drivendata.org/u/mlearn)\
**Post date:** [April 1, 2018, 8:42am UTC](https://community.drivendata.org/t/forecasting-energy-consumption-nwrmse/2173/10 "2018-04-01T08:42:24Z")

</div>

I’m still feeling mystified about the evaluation metric. I had been wondering whether the public leaderboard score was been based off a non-typical set but the private leaderboard scores are coming out similar. Will you be posting the test data so we can understand scoring better?

Thanks.
