# Sort order of predictions

**URL:** <https://forum.numer.ai/t/sort-order-of-predictions/2885>\
**Category:** Tournament\
**Created:** [April 15, 2021, 8:11pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885 "2021-04-15T20:11:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![flipperpie](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@flipperpie](https://forum.numer.ai/u/flipperpie)\
**Post date:** [April 15, 2021, 8:11pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/1 "2021-04-15T20:11:32Z")

</div>

I went to upload my predictions for the first time, but I noticed it doesn’t like the sort order. How exactly should the predictions be sorted? My system doesn’t use the order of the records in the tournament data, in fact that information is lost.

is it sorted by id? or are there other fields in sort as well?

---

<div class="post-metadata">

**Author:** ![flipperpie](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@flipperpie](https://forum.numer.ai/u/flipperpie)\
**Post date:** [April 15, 2021, 8:37pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/2 "2021-04-15T20:37:36Z")

</div>

it looks like the sort order is data\_type descending , era, id ascending but even that doesn’t work.

---

<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:** [April 15, 2021, 8:45pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/3 "2021-04-15T20:45:33Z")

</div>

Take a look at the example notebook and replicate how it does it, so you just have to put them back in the same order as you received them I guess. I didn’t actually know order mattered as I just copied their code for submitting.

> **[Google Colab](https://colab.research.google.com/github/numerai/example-scripts/blob/master/making-your-first-submission-on-numerai.ipynb)**

---

<div class="post-metadata">

**Author:** ![flipperpie](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@flipperpie](https://forum.numer.ai/u/flipperpie)\
**Post date:** [April 15, 2021, 9:15pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/4 "2021-04-15T21:15:09Z")

</div>

thanks, I’m not seeing the sort order in that notebook. I guess I need to iterate over the source file as I generate the predictions to get the sort order right.

my system loads the file and then does a lot of processing on it. So I’m trying to reconstruct the sort order but nothing I try seems to work

---

<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:** [April 15, 2021, 9:59pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/5 "2021-04-15T21:59:43Z")

</div>

This bit here

```auto
predictions_df = tournament_data["id"].to_frame()
predictions_df["prediction"] = predictions
predictions_df.head()

```

So as they didn’t change the order before making the predictions, the predictions are in the same order as in tournament\_data, so they can just add the predictions as a column next to the ids in tournament\_data.

So if you’ve lost the orderings you can just cache the ids in the order in tournament\_data, and then construct your predictions file using that ordering.

---

<div class="post-metadata">

**Author:** ![bcb](https://yyz1.discourse-cdn.com/flex009/user_avatar/forum.numer.ai/bcb/32/2724_2.png) [@bcb](https://forum.numer.ai/u/bcb)\
**Post date:** [April 16, 2021, 3:41pm UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/6 "2021-04-16T15:41:54Z")

</div>

The important part is to keep the relation of id \<-\> prediction as you need to provide both fields - no special ordering needed…

---

<div class="post-metadata">

**Author:** ![flipperpie](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@flipperpie](https://forum.numer.ai/u/flipperpie)\
**Post date:** [April 17, 2021, 2:26am UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/7 "2021-04-17T02:26:45Z")

</div>

well, I did manage to get it upload by generating the prediction file using the same ID order as the data file. The prediction file must have the same IDs and be in the same order to be accepted.

---

<div class="post-metadata">

**Author:** ![orbitalteapot](https://yyz1.discourse-cdn.com/flex009/user_avatar/forum.numer.ai/orbitalteapot/32/2403_2.png) [@orbitalteapot](https://forum.numer.ai/u/orbitalteapot)\
**Post date:** [April 17, 2021, 6:52am UTC](https://forum.numer.ai/t/sort-order-of-predictions/2885/8 "2021-04-17T06:52:26Z")

</div>

If using pandas you can use reindex:

predictions.reindex(tournament\_data.index)
