Numerai Python API¶
Automatically download and upload data for the Numerai machine learning competition.
This library is a Python client to the Numerai API. The interface is programmed in Python and allows downloading the training data, uploading predictions, and accessing user, submission and competitions information. It works for both, the main competition and the newer Numerai Signals competition.
If you encounter a problem or have suggestions, feel free to open an issue.
Installation¶
pip install --upgrade numerapi
Usage¶
Numerapi can be used as a regular, importable Python module or from the command line.
Some actions (like uploading predictions or staking) require a token to verify
that it is really you interacting with Numerai’s API. These tokens consists of
a public_id
and secret_key
. Both can be obtained by login in to Numer.ai and
going to Account -> Custom API Keys. Tokens can be passed to the Python module
as parameters or you can be set via environment variables (NUMERAI_PUBLIC_ID
and NUMERAI_SECRET_KEY
).
Python module¶
Usage example - main competition¶
import numerapi
# some API calls do not require logging in
napi = numerapi.NumerAPI(verbosity="info")
# download current dataset => also check `https://numer.ai/data`
napi.download_dataset("v4/train.parquet", "train.parquet")
# get current leaderboard
leaderboard = napi.get_leaderboard()
# check if a new round has started
if napi.check_new_round():
print("new round has started within the last 12hours!")
else:
print("no new round within the last 12 hours")
# provide api tokens
example_public_id = "somepublicid"
example_secret_key = "somesecretkey"
napi = numerapi.NumerAPI(example_public_id, example_secret_key)
# upload predictions
model_id = napi.get_models()['uuazed']
napi.upload_predictions("preds.csv", model_id=model_id)
# increase your stake by 1.2 NMR
napi.stake_increase(1.2)
# convert results to a pandas dataframe
import pandas as pd
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
Usage example - Numerai Signals¶
import numerapi
napi = numerapi.SignalsAPI()
# get current leaderboard
leaderboard = napi.get_leaderboard()
# setup API with api tokens
example_public_id = "somepublicid"
example_secret_key = "somesecretkey"
napi = numerapi.SignalsAPI(example_public_id, example_secret_key)
# upload predictions
model_id = napi.get_models()['uuazed']
napi.upload_predictions("preds.csv", model_id=model_id)
# get daily performance as pandas dataframe
import pandas as pd
df = pd.DataFrame(napi.daily_user_performances("uuazed"))
# using the diagnostics tool
napi.upload_diagnostics("preds.csv", model_id=model_id)
# ... or using a pandas DataFrame directly
napi.upload_diagnostics(df=df, model_id=model_id)
# fetch results
napi.diagnostic(model_id)
Command line interface¶
To get started with the cli interface, let’s take a look at the help page:
$ numerapi --help
Usage: numerapi [OPTIONS] COMMAND [ARGS]...
Wrapper around the Numerai API
Options:
--help Show this message and exit.
Commands:
account Get all information about your account!
check-new-round Check if a new round has started within...
competitions Retrieves information about all...
current-round Get number of the current active round.
daily-model-performances Fetch daily performance of a model.
daily-submissions-performances Fetch daily performance of a user's...
dataset-url Fetch url of the current dataset.
download-dataset Download specified file for the given...
download-dataset-old Download dataset for the current active...
leaderboard Get the leaderboard.
list-datasets List of available data files
models Get map of account models!
profile Fetch the public profile of a user.
stake-decrease Decrease your stake by `value` NMR.
stake-drain Completely remove your stake.
stake-get Get stake value of a user.
stake-increase Increase your stake by `value` NMR.
submission-filenames Get filenames of your submissions
submit Upload predictions from file.
transactions List all your deposits and withdrawals.
user Get all information about you!...
version Installed numerapi version.
Each command has it’s own help page, for example:
$ numerapi submit --help
Usage: numerapi submit [OPTIONS] PATH
Upload predictions from file.
Options:
--tournament INTEGER The ID of the tournament, defaults to 1
--model_id TEXT An account model UUID (required for accounts with
multiple models
--help Show this message and exit.
API Reference¶
Checkout the detailed API docs to learn about all available methods, parameters and returned values.
Contents¶
- Changelog
- [2.18.0] - 2024-03-08
- [2.17.0] - 2024-02-18
- [2.16.3] - 2024-01-01
- [2.16.2] - 2023-12-28
- [2.16.1] - 2023-10-09
- [2.16.0] - 2023-09-28 - submission downloads
- [2.15.1] - 2023-08-25 - model upload improvements
- [2.15.0] - 2023-07-13 - model uploads!
- [2.14.0] - 2023-04-06 - no more submission_status
- [2.13.4] - 2023-04-03
- [2.13.3] - 2023-04-03
- [2.13.2] - 2023-02-22
- [2.13.1] - 2023-02-15
- [2.13.0] - 2022-12-16 - “API deprecations”
- [2.12.9] - 2022-12-02
- [2.12.8] - 2022-11-21
- [2.12.7] - 2022-11-02
- [2.12.6] - 2022-11-01
- [2.12.5] - 2022-10-24
- [2.12.4] - 2022-08-24
- [2.12.3] - 2022-07-03
- [2.12.2] - 2022-06-30
- [2.12.1] - 2022-06-20
- [2.12.0] - 2022-06-17
- [2.11.0] - 2022-03-29
- [2.10.0] - 2022-02-07
- [2.9.4] - 2021-11-14
- [2.9.3] - 2021-11-12
- [2.9.2] - 2021-10-07
- [2.9.1] - 2021-09-27
- [2.9.0] - 2021-09-15
- [2.8.1] - 2021-09-08
- [2.8.0] - 2021-09-07 - “new data api”
- [2.7.1] - 2021-09-01
- [2.7.0] - 2021-08-27
- [2.6.0] - 2021-07-12
- [2.5.2] - 2021-06-30
- [2.5.1] - 2021-05-10
- [2.5.0] - 2021-05-09
- [2.4.5] - 2021-03-18
- [2.4.4] - 2021-03-04
- [2.4.3] - 2021-02-27
- [2.4.2] - 2021-02-25
- [2.4.1] - 2021-02-13
- [2.4.0] - 2021-01-12
- [2.3.9] - 2020-11-26
- [2.3.8] - 2020-10-27
- [2.3.7] - 2020-10-15
- [2.3.6] - 2020-10-07
- [2.3.5] - 2020-09-28
- [2.3.4] - 2020-08-10
- [2.3.3] - 2020-07-22
- [2.3.2] - 2020-07-21
- [2.3.1] - 2020-05-06 - “Signals”
- [2.3.0] - 2020-05-06 - “Signals”
- [2.2.4] - 2020-05-11
- [2.2.2] - 2020-05-09
- [2.2.0] - 2020-04-17
- [2.1.6] - 2020-04-08
- [2.1.5] - 2020-04-03
- [2.1.4] - 2020-03-30 - “Spring cleanup”
- [2.1.3] - 2020-03-30
- [2.1.2] - 2019-11-30
- [2.1.1] - 2019-11-23
- [2.1.0] - 2019-11-15
- [2.0.1] - 2019-10-28
- [2.0.0] - 2019-10-23
- [1.6.2] - 2019-07-31
- [1.6.1] - 2019-07-12
- [1.6.0] - 2019-07-10
- [1.5.5] - 2019-06-13
- [1.5.4] - 2019-05-30
- [1.5.3] - 2019-05-23
- [1.5.2] - 2019-05-22
- [1.5.1] - 2019-04-14
- [1.5.0] - 2019-04-03
- [1.4.6] - 2019-03-30
- [1.4.5] - 2019-03-05
- [1.4.4] - 2019-02-17
- [1.4.3] - 2019-02-17
- [1.4.2] - 2019-02-10
- [1.4.1] - 2019-02-10
- [1.4.0] - 2018-11-16
- [1.3.0] - 2018-08-09
- [1.2.1] - 2018-08-05
- [1.2.0] - 2018-08-03
- [1.1.1] - 2018-06-06
- [1.1.0] - 2018-05-24
- [1.0.1] - 2018-05-17
- [1.0.0] - 2018-04-25
- [0.9.1] - 2018-04-22
- [0.9.0] - 2018-04-13
- [0.8.3] - 2018-04-07
- [0.8.2] - 2018-03-09
- [0.8.1] - 2018-01-27
- [0.8.0] - 2018-01-06
- [0.7.1] - 2017-12-29
- [0.7.0] - 2017-12-29
- [0.6.3] - 2017-12-20
- License