This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
NewerOlder