Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Keras Callback to track Numerai consistency

Project description

A Keras callback that calculates your model’s consistency during training at each epoch. The callback prints the consistency and also adds the consistency at the end of each epoch to the training history under the consistency key.


Here is a usage example:

import pandas as pd
from numeraicb import Consistency
from keras.models import Sequential
from keras.layers.core import Dense

train = pd.read_csv('numerai_training_data.csv')
tourn = pd.read_csv('numerai_tournament_data.csv')

validation = tourn[tourn.data_type == 'validation']

features = ['feature{}'.format(i) for i in range(1, 51)]

X = train[features].values
Y =

X_validation = validation[features].values
Y_validation =

model = Sequential()
model.add(Dense(30, kernel_initializer='uniform', input_dim=X.shape[1], activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='adamax', loss='binary_crossentropy')

cb = Consistency(tourn)

# Now your models consistency will be printed at each epoch
history =, Y, callbacks=[cb], validation_data=(X_validation, Y_validation))

# Consistency is stored in the history as well
for epoch, consistency in enumerate(history.history['consistency']):
    print('consistency at epoch {}: {:.2%}'.format(epoch, consistency))

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for numeraicb, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size numeraicb-1.0.0-py2.py3-none-any.whl (4.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size numeraicb-1.0.0.tar.gz (15.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page