Skip to content

Instantly share code, notes, and snippets.

@talolard
talolard / ltsession.py
Last active October 17, 2019 08:14
Wrapper for working with LightTag API using the requests library
import requests
from functools import partial
class LTSession(requests.Session):
def __init__(self, workspace:str,user:str,pwd:str,host:str=None):
"""[summary]
Initializes a LightTag API session object
Arguments:
workspace {str} -- [The name of your workspace]
user {str} -- [Your LightTag Username]
pwd {str} -- [Your LightTag password]
@unpublished{LightTag,
AUTHOR = {Perry, Tal },
TITLE = {{LightTag}: A platform for managing text annotation projects
YEAR = {2018},
Note = {To appear}
}
@talolard
talolard / install-docker-compose.sh
Last active September 19, 2019 13:15 — forked from benfogel/install-docker-compose.sh
Installing docker-compose on Amazon Linux AMI
sudo yum update -y
sudo yum install -y docker
sudo usermod -a -G docker ec2-user
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose
sudo service docker start
sudo chkconfig docker on
sudo systemctl enable docker
@talolard
talolard / replacingWordsWithTags.ipynb
Last active February 28, 2019 12:07
replacingWordsWithTags.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@talolard
talolard / al.ipynb
Created January 17, 2019 09:35
Notebok showing active learning is dumb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@talolard
talolard / dirichlet.py
Created January 14, 2019 11:10
Sampling a portfolio from a dirichlet distribution
self.alphas= tf.contrib.layers.fully_connected(
inputs=l2,
num_outputs=num_stocks+1,
activation_fn=tf.nn.relu,
weights_initializer=tf.initializers.glorot_uniform)
self.alphas +=1
self.dirichlet = tfp.distributions.Dirichlet(self.alphas)
self.action = self.dirichlet._sample_n(1)
@talolard
talolard / crappy_env.py
Created January 14, 2019 10:54
A crappy environemtn for RL on a portfolio of stocks
import numpy as np
from collections import defaultdict
from env.priceGenerator import make_stock
costPerShare = 0 # 0.01
class Env:
'''
A simple environemnt for our agent,
the action our agent gives is weighting over the stocks + cash
@talolard
talolard / magic_market.py
Created January 14, 2019 10:36
How to make a market that is complex but learnable
import numpy as np
def make_stock(length=100, num_stocks=2):
alpha = 0.9
k = 2
cov = np.random.normal(0, 5, [num_stocks, num_stocks])
cov = cov.dot(cov.T) # This is a positive semidefinite matrix, e.g. a covariance matrix
A = np.random.multivariate_normal(np.zeros(num_stocks), cov, size=[length]) # sample noise, with covariance
B = np.random.multivariate_normal(np.zeros(num_stocks), cov, size=[length]) # sample another noise, with covariance
bs = [np.zeros(shape=num_stocks)] #
ps = [np.zeros(shape=num_stocks)] # The prices
@talolard
talolard / last_semver.py
Created June 5, 2018 19:46
Get the most recent semver tag for an ECR repo
import pprint
import boto3
import sys
repo_name = sys.argv[1]
print(repo_name)
client = boto3.client('ecr')
response = client.list_images(
repositoryName=repo_name,
filter={
'tagStatus': 'TAGGED'
@talolard
talolard / convert_to_json.py
Created March 23, 2018 17:10
Converting csv to json
import pandas as pd
D = pd.read_csv('./my_csv_file.csv')
D.to_json('./my_new_json_file.json',orient="records")