Get predictions
Read more: Overview
Do you want a swarm of fiercely competiting algorithms to predict your data? State of the art algorithms will find your stream of data and start predicting it. They even find relevant data. The quintessential use is live, public, frequently updated data. However there are many ways to use the API for private prediction if you are sneaky.
1. Install Microprediction
        pip install microprediction
      
See microprediction on PyPI.
2. Locate or create a live source of data
Take a look at this example. There is a function that returns a single number - the current speed of traffic on the Verrazano Narrows bridge. We will assume you have at your disposal a function like the following:
        def verrazano_speed():
          return fetch_live_data(key=VERRAZANO, field="speed")
      
3. Publish the live data periodically
Take a look at this example of a script that uses the MicroWriter to publish the speed every 20 minutes. You could do something even simpler such as:
        from microprediction import MicroWriter
        import time
        mw = MicroWriter(write_key="1586411f3ca74133384e2e33a474bdc3")   # <-- More on this in a moment
        while True:
          mw.set(name='mytrafficstream.json',value=verrazano_speed())
          time.sleep(60*20)
      
You may also wish to take advantage of some convenience classes provided in polling.py and looping.py which make it very easy to poll data or run data in a loop. See the polling_examples directory. For instance the following code uses the ChangePoll class to send changes in traffic speed to a stream similar to this stream.
        from microprediction.polling import ChangePoll
        from microprediction import new_key
        from microprediction.live import verrazano_speed

        try:
          from microprediction.config_private import TRAFFIC_WRITE_KEY
        except:
          TRAFFIC_WRITE_KEY = new_key(difficulty=12)  # Could take a while!

        if __name__=="__main__":
          changes = ChangePoll(write_key=TRAFFIC_WRITE_KEY,
                            name='verrazano_speed_change.json',
                            interval=1,
                            func=verrazano_speed)
          changes.run()
      
This code will poll every minute.
4. Let it run!
One suggestion for maintaining a long running process at little cost is provided in this article, though of course there are many ways to accomplish it.
5. See the results
Insert your write key into the dashboard
How do I get a write_key?
As you see in the examples above, you must possess a hash-memorable write_key of difficulty at least 12 in order to publish. Your options:
Questions?
Try the FAQ.