Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Holbrook ryanholbrook

View GitHub Profile
@ryanholbrook
ryanholbrook / forecasting_metrics.py
Last active May 12, 2021 — forked from bshishov/forecasting_metrics.py
Python Numpy functions for most common forecasting metrics
View forecasting_metrics.py
import numpy as np
EPSILON = 1e-10
def _error(actual: np.ndarray, predicted: np.ndarray):
""" Simple error """
return actual - predicted
View gist:5ff804433fa33e0b9b36e39beb6baebe
=
# +
import numpy as np
import matplotlib.pyplot as plt
plt.style.use("seaborn-whitegrid")
plt.rc('figure', autolayout=True)
plt.rc('axes',
labelweight='bold',
labelsize='large',
@ryanholbrook
ryanholbrook / schedule.py
Created May 1, 2021
Keras Optax Schedules
View schedule.py
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
from absl import logging
from typing import Callable, Dict, Union, Optional, Iterable, Sequence
from tensorflow import keras
from tensorflow.keras.optimizers.schedules import LearningRateSchedule
# Schedules ported from Optax
# https://github.com/deepmind/optax/blob/master/optax/_src/schedule.py
@ryanholbrook
ryanholbrook / optvis.py
Created Jan 9, 2021
Optimization Visualization
View optvis.py
import math
from itertools import product
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import tensorflow.keras as keras
from matplotlib import gridspec
# # Activation Model #
View gist:0e7bd1959c5dc13f8fc60cbca53ee4e3
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import matplotlib.pyplot as plt
from matplotlib import animation, rc
rc('animation', html='html5')
plt.style.use('seaborn-whitegrid')
@ryanholbrook
ryanholbrook / decision_boundary.org
Created Jan 18, 2020
R code for plotting and animating the decision boundaries
View decision_boundary.org

Classifiers

Introduction

Looking at the decision boundary a classifier generates can give us some geometric intuition about the decision rule a classifier uses and how this decision rule changes as the classifier is trained on more data.

Plotting Functions

@ryanholbrook
ryanholbrook / convex_aggregation.R
Created Oct 3, 2019
Convex Dirichlet Aggregation with brms and Parsnip
View convex_aggregation.R
library(brms)
library(parsnip)
## Fits a brms model
convex_regression <- function(formula, data,
family = "gaussian",
alpha = 1, gamma = 2, # Yang (2014) recommends alpha=1, gamma=2
verbose = 0,
...) {
if (gamma <= 1) {