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
using Flux | |
using Random | |
mutable struct SRUCell{M, V} | |
""" | |
W, Wⱼ, Wᵣ are the parameter matrices, and | |
vⱼ, vᵣ, bⱼ, bᵣ are the parameter vectors to be | |
learnt during training. | |
Note we change f -> j in paper for notational convenience | |
(there is no unicode subscript for f). |
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
library(tidyverse) | |
library(patchwork) | |
# CDC Covid-19 Excess Deaths | |
# https://data.cdc.gov/NCHS/Excess-Deaths-Associated-with-COVID-19/xkkf-xrst/ | |
df <- read_csv("https://data.cdc.gov/resource/xkkf-xrst.csv") | |
df %>% | |
filter(Outcome == "All causes", Type == "Unweighted") -> | |
df |
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
#' Lift to AUC | |
#' | |
#' @param percentiles | |
#' @param conversion_rate | |
#' | |
#' @return list | |
#' | |
#' @description | |
#' | |
#' This function takes in percentiles and the conversion rate, |
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
using Flux | |
# Input data, of (features, examples, time_step) | |
# We ignore masking | |
x = randn(Float32, 32, 100, 12) | |
hidden_states = Chain( | |
# A 4-layer stacked LSTM | |
LSTM(32, 64), | |
LSTM(64, 64), |
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
library(tidyverse) | |
library(patchwork) | |
crashes <- read_csv("~/Downloads/Motor_Vehicle_Collisions_-_Crashes.csv") | |
vehicles <- read_csv("~/Downloads/Motor_Vehicle_Collisions_-_Vehicles.csv") | |
vehicles %>% | |
group_by(COLLISION_ID) %>% | |
summarise( | |
out_of_state = sum(STATE_REGISTRATION != "NY", na.rm = TRUE), |
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
library(tidyverse) | |
df <- read_csv("https://raw.githubusercontent.com/nychealth/coronavirus-data/master/latest/now-cases-by-day.csv") | |
df %>% | |
mutate(date = as.Date(date_of_interest, "%m/%d/%Y")) ->df | |
df %>% | |
ggplot(aes(date, BK_CASE_COUNT)) + | |
geom_point() |
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
from tensorflow.keras.datasets import imdb | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.metrics import roc_auc_score | |
(x_train, y_train), (x_test, y_test) = imdb.load_data() | |
w2i = imdb.get_word_index() | |
i2w = {v: k for k, v in w2i.items()} | |
review_train = [" ".join([i2w[i] if i in i2w else '' for i in x]) for x in x_train] |
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
library(tidyverse) | |
library(alfred) | |
series <- tribble( | |
~Series, ~Name, | |
"CEU3000000001", "All Employees - Manufacturing", | |
"JTU3000HIR", "Hires", | |
"JTU3000LDR", "Layoffs", | |
"JTU3000QUR", "Quits" | |
) |
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
library(needs) | |
# gganimate: devtools::install_github("dgrtwo/gganimate") | |
needs(ggplot2, gganimate, dplyr, viridis) | |
# HadCRUT4.4 | |
file_url = "http://www.metoffice.gov.uk/hadobs/hadcrut4/data/current/time_series/HadCRUT.4.4.0.0.monthly_ns_avg.txt" | |
if(!file.exists("data.txt")) download.file(file_url, "data.txt") | |
read.table("data.txt", "", header = F, stringsAsFactors = F) %>% | |
mutate(Date = as.Date(sprintf("%s/01", V1), "%Y/%m/%d")) %>% |