Python Module 3

Retrieving historical data

Retrieving historical data

In the previous module we submitted predictions to a single data stream.

Now, we show how to retrieve historical data (lagged values) using the Python client, or the api directly, or CSV links.  



Here are the steps, also shown in a notebook.

(a) Instantiate MicroReader

Unlike Modules 1 and 2, we don't need a write key as we can instead instantiate a "mere" MicroReader

pip install microprediction

Then we import

from microprediction import MicroReader

and instantiate 

reader = MicroReader()

Getting lagged values is as easy as


so long as you remember the .json (thus, not so easy :-).  

(b) CSV and API links

As an alternative, you can download CSV data as shown here or use the API directly (for example try clicking on


Use methods like get_lagged_values or get_lagged_times to retrieve historical data.

MicroReader.get_<this or that>

The microprediction/ code lists the get methods you can use to retrieve data of various kinds.  

MicroWriter, MicroCrawler 

If you are using a MicroWriter or MicroCrawler, or perhaps a fancier version like FitCrawler, you will have access to the same reader get methods because they all inherit from MicroReader. 


In the next module we will show how to create a data stream