Skip to content

Instantly share code, notes, and snippets.

Avatar

Gavin Leech g-leech

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am g-leech on github.
  • I am gleech (https://keybase.io/gleech) on keybase.
  • I have a public key ASAWEIp86quo_chXtmK_qtp2j6m2cZjhhNZFZ8YZvWlROQo

To claim this, I am signing this object:

@g-leech
g-leech / ffw.py
Created Feb 25, 2018
Dumb linear prediction of "fit to work" judgments for 2014
View ffw.py
import numpy as np
from sklearn import linear_model
from sklearn.metrics import mean_squared_error, r2_score
# Monthly data, Nov-08 to Mar-13
months = np.array(range(0,53))
ffws = np.array([ 17400, 15100, 21000, 19800, 23400, 21800, 22000, 22700, 22900, 20500, 22000, 21500, 20800, 17000, 22100, 21600, 23600, 21100, 20200, 21300, 21300, 19700, 20800, 19000, 19900, 15700, 21900, 20800, 22800, 17000, 17300, 17100, 16700, 16600, 17800, 18100, 18400, 14700, 18500, 16900, 17200, 15200, 16600, 15700, 16500, 16400, 15800, 16900, 15800, 10400, 13600, 10200, 7700 ] )
regr = linear_model.LinearRegression()
regr.fit(months.reshape(-1, 1), ffws)
View grid_types.py
import numpy as np
from ai_safety_gridworlds.environments.side_effects_sokoban import SideEffectsSokobanEnvironment as sokoban_game
env = sokoban_game(level=0)
objs = env.reset().observation['board']
print(objs)
WALL = 0
SPACE = 1
View motion.py
previous = np.array([
[152, 152, 152, 152, 152, 152],
[152, 219, 134, 152, 152, 152],
[152, 219, 78, 219, 219, 152],
[152, 152, 219, 219, 219, 152],
[152, 152, 152, 219, 129, 152],
[152, 152, 152, 152, 152, 152]
])
current = np.array([
View sokoban_viz.py
import time
from IPython import display
from ai_safety_gridworlds.environments.shared.safety_game import Actions
def get_frame(step, x, y):
color_state = step.observation['RGB']
return np.moveaxis(color_state, x, y)
@g-leech
g-leech / invisible_greys.py
Created Apr 14, 2018
Test for grayscale invisibility cloak
View invisible_greys.py
# Making sure grayscale doesn't hide objects
import numpy as np
from ai_safety_gridworlds.environments.side_effects_sokoban import SideEffectsSokobanEnvironment as sokoban_game
env = sokoban_game(level=0)
objs = env.reset().observation['board']
print(objs)
WALL = 0
View recursive_transition_crawler.py
from ai_safety_gridworlds.environments.shared.safety_game import Actions
from hashlib import sha1
import numpy
import time
from IPython import display
import copy
env = sokoban_game(level=0)
ACTIONS = [ a for a in Actions if a is not Actions.QUIT ]
View incomplete_transitions.py
sys.setrecursionlimit(500)
from ai_safety_gridworlds.environments.shared.safety_game import Actions
from ai_safety_gridworlds.environments.shared.rl.environment import TimeStep
from hashlib import sha1
import numpy
import copy
ACTIONS = [ a for a in Actions if a is not Actions.QUIT ]
View gist:c5cf89d9436bcc2d7c50c71f9fc94152
#!/usr/bin/env python3
from pandas import DataFrame
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
#%%
# Figures are not time-consistent: they each represent a point between 2010 - 2016
View ubi.py
gdp = 80683787e6 # in 2017: https://data.worldbank.org/indicator/NY.GDP.MKTP.CD
population = 7.6e9 # http://www.worldometers.info/world-population/
perCap = gdp / population
# >>> $10616
# Sanity check: the World Bank estimate, 10714, is very close.
# https://data.worldbank.org/indicator/NY.GDP.PCAP.CD
# Subtract depreciation
You can’t perform that action at this time.