Package: numerauto
NumerautoNumerauto is a Python daemon that facilates automatic weekly participation in
the Numerai machine learning competition (http://numer.ai).Users can implement custom event handlers to handle new training data, apply
models to new tournament data when a new round starts, and more. Example
event handlers are included for training SKLearn classifiers and uploading
predictions.If you encounter a problem or have suggestions, feel free to open an issue.InstallationTo install the latest release:pip install --upgrade numerautoIf you prefer to use the latest development version, clone this github reposistory:git clone https://github.com/thebrain85/numerautoAnd then run the following command in the numerauto directory.python setup.py installUsageExampleAlthough Numerauto can be run without any event handlers for testing, it will
not do anything except detecting round changes and downloading the new dataset
every week.Seeexample.pyfor a basic example that trains a scikit-learn logistic
regression model and uploads its predictions.The example uses thePredictionUploaderevent handler to upload predictions
to Numerai. This requires you to register an API key in your Numerai account.
This can be done in Account settings -> Your API Keys -> Add. Select
'Upload submissions' to be able to upload predictions using this API key. Replace
'insert your publickey/secretkey here' in the code with your own API public/secret
API key pair to allow the example code to upload the prediction to your account.Seeexample2.pyfor an example that uses theCommandlineExecutorevent
handler to call a custom commandline once a new round is detected. You can
modify the command line to execute your own code, e.g.python myscript.py,
like you would do manually. This is an easy and quick way to make use of
Numerauto's automatic detection of new rounds in Numerai.Custom event handlersImplementing your own event handler is easy. Simply create a subclass of
numerauto.eventhandlers.EventHandler and overload the on_* methods that you
need to implement your own functionality. The event handler can then be added
to a Numerauto instance using theadd_event_handlermethod. Then start the
main loop of the Numerauto daemon by calling therunmethod.Currently these events are supported:def on_start(self): Called when the daemon starts.def on_shutdown(self): Called when the daemon shuts down.def on_round_begin(self, round_number): Called when a new round has started.def on_new_training_data(self, round_number): Called when the daemon has detected that new training data is available.def on_new_tournament_data(self, round_number): Called every round to signal that there is new tournament data.Note that event handlers are called in the order they are added to the
Numerauto instance. Also note that all handlers for one event are called before
the next event is handled, keep this in mind when designing event handlers that
interact with one another, or that keep large amounts of data in memory.
Ideally, the handler should clean up memory inon_new_tournament_datato
prevent memory being used while the daemon is idle and waiting for the next
round.Running NumerautoBy default, therunmethod of Numerauto will keep running indefinitely until
interrupted using a SIGINT (ctrl-c) or SIGTERM signal. This way, you only have
to start your Numerauto script once, for example on startup, or running insidescreenon linux.example.pyruns Numerauto this way.Alternatively, you can provide the argumentsingle_runto therunmethod of
Numerauto. This will cause Numerauto to only wait once for a new round (and with
a maximum of 24 hours). This is ideally suited for calling Numerauto from a
task scheduler, such as cron on Linux or the Windows Task Scheduler. Make sure
you schedule Numerauto to run a little before the official round start time,
it will wait and run as soon as the dataset is available.example2.pyruns Numerauto this way.Persistent state: state.pickleNumerauto stores a persistent state in thestate.picklefile in the directory
from which the daemon is being run. By default, the Numerauto daemon stores
the last round number that was processed (last_round_processed) and the last
round number on which training was performed (last_round_trained). You can
force the system to reprocess and retrain by stopping the daemon and removing
the state.pickle file.Custom event handlers can store persistent information in thepersistent_statedictionary of the Numerauto instance.Round reportEvent handlers have access to a special dictionary in the numerauto instance
viaself.numerauto.report. This dictionary is reset every round and can be
used to report values that are relevant to the event handler. For example,SKLearnModelTrainerreports back the filenames of the trained model (if
applicable) and the generated predictions, andPredictionStatisticsGeneratorreports the validation metrics of a prediction.The report can be written to file every round withBasicReportWriter, or
emailed withBasicReportEmailer, both using only simple formatting.