Skip to content

Instantly share code, notes, and snippets.

@microprediction
microprediction / submit.py
Created February 18, 2020 18:14
Supercollider submission example
import Algorithmia
import numpy as np
import json
# Only works inside Algorithmia, but easily modified
sc_pred = Algorithmia.client().algo('microprediction/sc_predict')
NUM_PREDICTIONS = Algorithmia.client().algo('micropredictoin/sc_num').pipe("").result
write_key = json.loads("data://.my/threeza_private/write_key.json").getString())['key']
scenarios = sorted(list(np.random.randn(NUM_PREDICTIONS))
predictions = {"name":"cop.json","write_key":write_key,"values":scenarios}
import requests
ANIMALS = requests.get('https://gist.githubusercontent.com/atduskgreg/3cf8ef48cb0d29cf151bedad81553a54/raw/82f142562cf50b0f6fb8010f890b2f934093553e/animals.txt').text.split('\n')
def animals_of_len(k):
return [ a.lower() for a in ANIMALS if len(a)==k ]
from microprediction import MicroWriter
import time
from pprint import pprint
import numpy as np
# Enters all the z1 streams
# This might be run once a day, say.
from microprediction import new_key
WRITE_KEY = new_key(difficulty=10)
from getjson import getjson
from pprint import pprint
# Human : "I don't see who is winning what."
# Crawler: "Hold my beer ..."
def descend(d):
return {k: v for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)}
@microprediction
microprediction / picklecached.py
Created September 24, 2020 20:38
Decorator that caches intermediate research dataframes
CACHE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))+'/cache/'
def picklecached():
"""
A function that creates a decorator which will use "cachefile" for caching the results of the decorated function "fn".
Also stores a CSV so we can quickly inspect the result ... though only pickles are used in loading.
"""
def decorator(fn): # define a decorator for a function "fn"
@microprediction
microprediction / emoji_prediction.jl
Last active September 28, 2020 22:43
Julia code for rudimentary emoji prediction
using Microprediction
using Distributions
write_config = Microprediction.Config("66a78936 YOUR KEY HERE 6482eb36249a")
test_stream_name = "emojitracker-twitter-grinning_face_with_smiling_eyes.json"
function make_sample()
values = Microprediction.get_lagged_values(write_config, test_stream_name)
good_values = values[1:50]
distribution = fit(Poisson, convert(Array{Int64}, good_values))
@microprediction
microprediction / datasciencejobs.txt
Created March 25, 2021 19:17 — forked from ryanswanstrom/datasciencejobs.txt
A collection of 16 data scientist job posts
Job Category: IT
Location: United States, WA, Redmond
Job ID: 786045
Product: (Not Product Specific)
Division: IT
The Data & Decision sciences Team within technology Office in MSIT, helps drive actionable business intelligence through advanced statistical modeling and business analytics, throughout Microsoft. The team focuses on enterprise level engagement, where advanced data mining and modeling skills are needed to find business insights. We have a strong team of experienced statistician with an average experience of 15+ years in various industries. Currently we are expanding our work in areas of simulation, system modeling and text mining, to support our internal clients. Our goal is to support business performance enabled through data analysis, statistical modeling - resulting into business impact. Candidate will be expected to work with internal clients on analytic projects and identify potential improvement opportunities. The candidate must possess a passion for advanced analytics and skills in areas of
@microprediction
microprediction / at_least_2d_column.py
Last active February 17, 2023 03:43
Force numpy array to be column or row
def at_least_2d_column(x):
return at_least_2d_row(x).T
def at_least_2d_row(x):
return np.atleast_2d(np.ravel(x))
import time
def intrinio_last_price(ticker, api_key=INTRINIO_KEY):
from getjson import getjson
template_url = 'https://api-v2.intrinio.com/securities/TICKER/prices/realtime?api_key=API_KEY'
url = template_url.replace('TICKER',ticker.upper()).replace('API_KEY',api_key)
try:
return getjson(url)['last_price']
except:
time.sleep(0.2)