Skip to content

Instantly share code, notes, and snippets.

View gajomi's full-sized avatar

Gabriel Joel Mitchell gajomi

View GitHub Profile
@gajomi
gajomi / baseline_markov.py
Created November 18, 2020 18:19
Baseline loss functions for first order markov chains
"""
Quick tutorial on comparing loss function for a fitted markov chain model to `baselines`.
Illustrates the effect of randomness in data.
Shows principle behind following gradients of loss to optimize the parameters
"""
import torch
from torch import tensor
from torch import nn
from torch.nn import Softmax
@gajomi
gajomi / instructions.txt
Created March 25, 2020 04:05
Healthcare data engineering with pandas practice problem
Instructions:
(1) Load ICD category code descriptions into dataframe. Do not store the file on disk.
url: https://github.com/kamillamagna/ICD-10-CSV/blob/master/categories.csv?raw=true
(2) Load ICD block descriptions into a dataframe. Do no store any files to disk
url: https://www.aapc.com/icd-10/
hint: consider using `pd.read_html`
(3) Count all the icd10 codes characterized as diseases according to the ICD block description
(4) From the codes in step (3) isolate though refering to 'viral' or 'virus' and concatenate, separating by semicolon
@gajomi
gajomi / albert_oscillations.py
Created February 14, 2020 00:19
albert hidden state oscillations (are there any?)
import matplotlib.pyplot as plt
import torch
import numpy as np
from transformers import *
def get_albert_model(albert_model_name = 'albert-large-v2'):
"""get an albert model from name for thei experiment"""
model_class, tokenizer_class, pretrained_weights = (AlbertModel, AlbertTokenizer, albert_model_name)
tokenizer = tokenizer_class.from_pretrained(pretrained_weights)
model = model_class.from_pretrained(pretrained_weights, output_hidden_states=True, output_attentions=True)
@gajomi
gajomi / rando.ipynb
Created November 19, 2018 23:27
random gaussian process thingy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gajomi
gajomi / bionumberspandas.ipynb
Created September 4, 2018 20:00
Parse bionumbers DB dump into pandas dataframe with units
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gajomi
gajomi / blackberries.py
Created September 4, 2018 02:46
seattle blackberry observations
import urllib.request, json
import pandas as pd
urlstr = "https://api.inaturalist.org/v1/observations?captive=false&taxon_name=Rubus&year=2018&lat=47.6&lng=-122.3&radius=50&order=desc&order_by=created_at"
with urllib.request.urlopen(urlstr) as url:
data = json.loads(url.read().decode())
def parse_observation(observation):
data = {}
data['species'] = observation['taxon']['name']
@gajomi
gajomi / nbtest.ipynb
Last active March 8, 2018 18:42
nbviwertest
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gajomi
gajomi / benchmacro.jl
Last active February 19, 2016 06:47
unique and union! benchmarks
macro stats(setupexpr,testexpr)
quote
N = 2^8
results = zeros(N,3)
for i = 1:N
$setupexpr
data = @timed $testexpr
results[i,1] = data[2]
results[i,2] = Float64(data[3])
results[i,3] = data[4]
@gajomi
gajomi / benchmacro.jl
Last active February 9, 2016 08:23
Benchmarks for unique and union methods
macro stats(setupexpr,testexpr)
quote
N = 2^8
results = zeros(N,3)
for i = 1:N
$setupexpr
data = @timed $testexpr
results[i,1] = data[2]
results[i,2] = Float64(data[3])
results[i,3] = data[4]