# The basic examples Modeling/Submissions are not working, please help

**URL:** <https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760>\
**Category:** Tournament\
**Created:** [October 20, 2022, 7:30pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760 "2022-10-20T19:30:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![edddie](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@edddie](https://forum.numer.ai/u/edddie)\
**Post date:** [October 20, 2022, 7:30pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/1 "2022-10-20T19:30:38Z")

</div>

The code below yields the following error message:

* * *

AttributeError Traceback (most recent call last)  
~\AppData\Local\Temp/ipykernel\_11660/55592206.py in   
1 # submit predictions to numer.ai  
2 predictions = model.predict(tournament\_data[feature\_names])  
----\> 3 predictions.to\_csv(“predictions.csv”)

AttributeError: ‘numpy.ndarray’ object has no attribute ‘to\_csv’

##########################################################################

import pandas as pd  
from xgboost import XGBRegressor

# training data contains features and targets

training\_data = pd.read\_csv(“numerai\_training\_data.csv”).set\_index(“id”)

# tournament data contains features only

tournament\_data = pd.read\_csv(“numerai\_tournament\_data.csv”).set\_index(“id”)  
feature\_names = [f for f in training\_data.columns if “feature” in f]

# train a model to make predictions on tournament data

model = XGBRegressor(max\_depth=5, learning\_rate=0.01,   
n\_estimators=2000, colsample\_bytree=0.1)  
model.fit(training\_data[feature\_names], training\_data[“target”])

# submit predictions to numer.ai

predictions = model.predict(tournament\_data[feature\_names])  
predictions.to\_csv(“predictions.csv”)

---

<div class="post-metadata">

**Author:** ![edddie](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@edddie](https://forum.numer.ai/u/edddie)\
**Post date:** [October 20, 2022, 7:34pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/2 "2022-10-20T19:34:43Z")

</div>

I solved the issue above with: pd.DataFrame(predictions).to\_csv(“predictions.csv”)  
But then comes the next problem. Uploading of the predictions is not working.  
This line of code:  
napi.upload\_predictions(“predictions.csv”, model\_id=“my model”)  
yields the following error message:  
Specified model\_id is not a UUID

---

<div class="post-metadata">

**Author:** ![edddie](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@edddie](https://forum.numer.ai/u/edddie)\
**Post date:** [October 20, 2022, 7:38pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/3 "2022-10-20T19:38:18Z")

</div>

I tried this:

import uuid  
model = str(uuid.uuid4())  
napi.upload\_predictions(“predictions.csv”, model\_id=model)

This yields the following error message:  
Unable to resolve model from id.

---

<div class="post-metadata">

**Author:** ![shatteredx](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@shatteredx](https://forum.numer.ai/u/shatteredx)\
**Post date:** [October 20, 2022, 7:41pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/4 "2022-10-20T19:41:14Z")

</div>

You need to pass your actual model id that you can get from [Numerai](https://numer.ai/models)

---

<div class="post-metadata">

**Author:** ![edddie](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@edddie](https://forum.numer.ai/u/edddie)\
**Post date:** [October 20, 2022, 7:47pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/5 "2022-10-20T19:47:23Z")

</div>

Thanks a lot, now I have the next problem:

Invalid submission headers. Headers must be id and prediction.

---

<div class="post-metadata">

**Author:** ![shatteredx](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@shatteredx](https://forum.numer.ai/u/shatteredx)\
**Post date:** [October 20, 2022, 8:04pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/6 "2022-10-20T20:04:23Z")

</div>

OK, you need to do something like this to put id and predictions headers in your submission csv:

```auto
#download live data
current_round = napi.get_current_round(tournament=8)
napi.download_dataset("v4/live_int8.parquet", f"live_{current_round}_int8.parquet")
live_data = pd.read_parquet(f"live_{current_round}_int8.parquet")

#put predictions into live data dataframe
live_data["prediction"] = model.predict(live_data[feature_names])

#make new dataframe with only the index (contains ids)
predictions_df = live_data.index.to_frame()
#copy predictions into new dataframe
predictions_df["prediction"] = live_data["prediction"].copy()

#csv file will have only id and prediction headers/columns
predictions_df.to_csv("predictions.csv", index=False)
submission_id = napi.upload_predictions("predictions.csv", model_id=model_id)

```

I’m sure there’s more elegant code to do this. This is just my amateur hack code.

---

<div class="post-metadata">

**Author:** ![edddie](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@edddie](https://forum.numer.ai/u/edddie)\
**Post date:** [October 21, 2022, 6:50pm UTC](https://forum.numer.ai/t/the-basic-examples-modeling-submissions-are-not-working-please-help/5760/7 "2022-10-21T18:50:37Z")

</div>

Thank you very much, I will try it out! 🙂
