NoneType error on Upload_Prediction

I am using Google Colab and I am getting a [‘NoneType’ object is not subscriptable] when calling the [upload_predictions] method. I know that my model_id value is correct since I use it early to set up my connection. Any ideas?

Hard to say exactly what’s going on without the full stack trace. But your code should look something like this:

# Get your API keys and model_id from
public_id = "REPLACEME"
secret_key = "REPLACEME"
model_id = "REPLACEME"
napi = numerapi.NumerAPI(public_id=public_id, secret_key=secret_key)
# Upload your predictions
predictions_df.to_csv("predictions.csv", index=False)
submission_id = napi.upload_predictions("predictions.csv", model_id=model_id)

Here’s what it means for an object to be subscriptable:

So it sounds like it is trying to iterate over something (probably the data), and something is going wrong there. So make sure your predictions.csv is in the correct format, probably something wrong about it.

I will take a look at that. The web upload worked just fine so there must be something that the code is checking. I will test a few things the next time I submit my predictions.

I changed the format of my csv and it still isn’t working. It does appear to be an issue with authorization as I get this error:

ERROR numerapi.utils: Oops, something went wrong: Invalid return character or leading space in header: Authorization

Sounds like there’s something wrong with your keys and/or model-id then. Print the values and make sure they’re what you expect they are. Applying strip to them might allow it to work, if it does it means you’ve got spaces and/or newline characters in your variables.

I will give that a shot. I removed my numeric id columns and used the correct id column and that still didn’t work.

Try just uploading the CSV manually to the NumerAI site, that way you have something in before submissions close for round 256. If it’s accepted then you know that something is wrong with your code and you should troubleshoot that during the week.

If it’s not accepted then you know something is wrong with your CSV. Make sure you’re predicting the most recent dataset (the number of rows changes in the tournament dataset every week). Also make sure your columns are labeled exactly as shown in the example predictions CSV and format everything exactly like the example.

Good luck!

Going through the web site worked fine. Do you know where the “official” documentation is for the submission? I have seen it a few places.

My csv file has “id” and “prediction” as the column headers and then the data. Is that correct? The example python script shows it just writing out the predictions.

I want to thank everyone for their help. It appears that my private keys had “\n” at the end of them.

I am now getting the “session is invalid or has expired” so I will give it another shot for 257


You still have this whole week to upload 256 – it will just be late (can’t stake, doesn’t count for rep). You’ll still get scores though.

Sorry, I wasn’t very clear. I was able to upload through the web site. When I said “give it another shot” I mean give my Colab notebook another shot to upload.

Righto. If your submission was late though, you can overwrite it (even with the same thing) so you could still work on that if you wanted. Or create another model on your account to play with…

It’s those small little bugs that are the most annoying, haha! Glad you were able to diagnose the problem

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:


NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return a value will return None . In general, the error means that you attempted to index an object that doesn’t have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. This is a design principle for all mutable data structures in Python.