Skip to main content

microprediction

Collective microprediction client leveraging www.microprediction.org

pip install microprediction 

Read client

It is possible to retrieve most quantities at www.microprediction.org with direct web calls such as https://www.microprediction.org/live/cop.json. For example:

import requests
lagged_values = requests.get('https://www.microprediction.org/live/lagged_values::cop.json').json()
lagged        = requests.get('https://www.microprediction.org/lagged/cop.json').json()

However the reader client adds a little convenience.

from microprediction import MicroReader
mr = MicroReader()

summary       = mr.get_summary('cop.json')
current_value = mr.get('cop.json')
lagged_values = mr.get_lagged_values('cop.json') 
lagged_times  = mr.get_lagged_times('cop.json')
delayed       = mr.get_delayed('cop.json',delay=70)

Your best reference is the code https://github.com/microprediction/microprediction/blob/master/microprediction/reader.py

Write client

The write client is used to submit predictions or to create a data stream.

Submitting predictions

To predict a data stream at www.microprediction.org is to supply a collection of scenarios. These scenarios are quarantined for different horizons (see delays parameter at https://www.microprediction.org/config.json ). When the data is updated by the stream owner, rewards are calculated. People and machines making accurate probabilistic forecasts will see their balances (at www.microprediction.org/balance/YOUR_WRITE_KEY) rise.

Step 1: Obtaining a write_key (muid.org)

Click on http://www.muid.org/create/ to create a write_key. Hash memorable keys are explained at https://vimeo.com/397352413

Step 2: Instantiate a writer

from microprediction import MicroWriter
mw = MicroWriter(write_key=)    # Sub in your own write_key 

Step 3: Submitting scenarios

scenarios = [ i*0.001 for i in range(mw.num_predictions) ] 
mw.submit(name='cop.json',values=scenarios)    

There is no difference when predicting regular streams and derived streams. For example to predict the implied z-score:

my_scenarios = sorted(list(np.random.randn(mw.num_predictions))
mw.submit(name="z1~airp-06820.json", write_key="ce169feeb3565b282d50a850dc62e0db", values = my_scenarios, delay=15)

Step 4: Examine performance

Visit leaderboards such as www.microprediction.org/leaderboards/cop.json or look across all streams with:

mw.get_performance()

Submitting data to be predicted

You can also use the writer to create a stream of live data that clever algorithms and humans can predict.

mw = MicroWriter(write_key=write_key)

However there is a higher barrier to entry...

Step 1: Obtaining a rare write_key

To create a new stream you need:

muid.difficulty(write_key)  >  official minimum difficulty     # 12 at time of writing

See https://www.microprediction.org/config.json for the current values of min_len, which is the official minimum difficulty to create a stream. To mine for write_keys with this property you can cut and paste this bash command into terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/microprediction/muid/master/examples/mine_from_venv.sh)"

or use the MUID library (www.muid.org) ...

$pip install muid
$python3
>>> import muid
>>> muid.mine(skip_intro=True)

See www.muid.org or https://vimeo.com/397352413 for more on MUIDs. Use a URL like http://www.muid.org/validate/fb74baf628d43892020d803614f91f29 to reveal the hidden "spirit animal" in a MUID. The difficulty is the length of the animal, not including the space.

Step 2: Updating the current value

To create a new live data source or update its value:

prctl = mw.put(name='mystream.json',value=3.14157) 

By default this returns a percentile so you know how surprising the data point is, relative to the CDF of predictions made by others at some time in the past.

Step 3: Retrieve the distribution of future values

You can see what others think about the future of your data as follows:

 cdf = mw.get_cdf('cop.json',delay=mr.delays[0],values=[0,0.5])

where the delay parameter, in seconds, acts as a prediction horizon. This call will reveal the probability that your future value is less than 0.0, and the probability that it is less than 0.5.

Step 4: Hope that your write_key does not go broke

When you create a stream you automatically participate in the prediction of the stream. A benchmark empirical sampling algorithm with some recency adjustment is used for this purpose. If nobody can do a better job that this, your write_key balance will generally neither rise nor fall.

However once smart people and algorithms enter the fray, you can expect this default model to be beaten and the balance on your write_key to trend downwards. On an ongoing basis you also need the write_key balance not to fall below a threshold bankruptcy level. The minimum balance for a key of difficulty 8 is also found at https://www.microprediction.org/config.json. At time of writing, and assuming this parameter is -10, we have:

write_key difficulty bankruptcy write_key difficulty bankruptcy
8 -10 11 -40,960
9 -160 12 -655,360
10 -2,560 13 -10,485,760

Higher dimensional prediction (copulas, Z-curves)

Advanced functionality is available to those with write_keys of difficulty 1 more than the stream minimum. More details to follow on that.

Stream name rules

  • Must end in .json
  • Must contain only alphanumeric, hyphens, underscores, colons (discouraged) and at most one period.
  • Must not contain double colon.

Troubleshooting

Try:

mw.get_errors()
mw.get_warnings()
me.get_confirmations()

which are also available directly. For example:

error_log = requests.get('https://www.microprediction.org/live/errors::53e6fbba-2dcd-486c-a4ab-14759db58dde.json').json()
error_log = requests.get('https://www.microprediction.org/errors/53e6fbba-2dcd-486c-a4ab-14759db58dde').json()

Metadata

Release files for microprediction 0.1.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microprediction 0.1.36
File Size Uploaded
microprediction-0.1.36.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microprediction 0.1.36
File Interpreter ABI Platform
microprediction-0.1.36-py3-none-any.whl Python 3 none any Details

Total release size: 38.8 kB

Release files / microprediction-0.1.36.tar.gz

Download URL microprediction-0.1.36.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ab6cdb81384f99b6395d28518565fef1c97bf316a20007229b6eea99ca0baf6
BLAKE2b-256 checksum
How to use checksums
034b6af9ebbb86d17a262f1c87ccfcc4a3ee60d0688cff836ddf8bc70122f875
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / microprediction-0.1.36-py3-none-any.whl

Download URL microprediction-0.1.36-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1d379909cad4f9f4726e0261b5ffe01340abb2fffbc104bd38a8c3114a1a7c7
BLAKE2b-256 checksum
How to use checksums
b35f8a95582d0ad9ed79cdd495df131c14c25e2d7c019b686dcf51f64a940e52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release history Release notifications | RSS feed

1.2.0

2 release files

1.1.34

2 release files

1.1.33

2 release files

1.1.32

2 release files

1.1.31

2 release files

1.1.30

2 release files

1.1.29

2 release files

1.1.27

2 release files

1.1.25

2 release files

1.1.24

2 release files

1.1.23

2 release files

1.1.22

2 release files

1.1.21

2 release files

1.1.13

2 release files

1.1.12

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.5

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.26

2 release files

1.0.24

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.15

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.23.0

2 release files

0.21.3

2 release files

0.21.2

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.4

2 release files

0.20.3

2 release files

0.20.1

2 release files

0.20.0

2 release files

0.19.5

2 release files

0.19.3

2 release files

0.19.2

2 release files

0.19.1

2 release files

0.19.0

2 release files

0.18.8

2 release files

0.18.4

2 release files

0.18.1

2 release files

0.17.7

2 release files

0.17.6

2 release files

0.17.5

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.7

2 release files

0.16.5

2 release files

0.16.4

2 release files

0.16.2

2 release files

0.15.7

2 release files

0.15.5

2 release files

0.15.4

2 release files

0.15.3

2 release files

0.15.2

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.11.9

2 release files

0.11.8

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.29

2 release files

0.9.27

2 release files

0.9.21

2 release files

0.9.18

2 release files

0.9.17

2 release files

0.9.9

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.5.15

2 release files

0.5.14

2 release files

0.5.13

2 release files

0.5.11

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.4.9

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.39

2 release files

0.1.38

2 release files

This release

0.1.36 This release

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page