Skip to content

Instantly share code, notes, and snippets.


Ryan Holbrook ryanholbrook

View GitHub Profile
ryanholbrook /
Last active May 12, 2021 — forked from bshishov/
Python Numpy functions for most common forecasting metrics
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"seaborn-whitegrid")
plt.rc('figure', autolayout=True)
ryanholbrook /
Created May 1, 2021
Keras Optax Schedules
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
ryanholbrook /
Created Jan 9, 2021
Optimization Visualization
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')'seaborn-whitegrid')
ryanholbrook /
Created Jan 18, 2020
R code for plotting and animating the decision boundaries



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 / convex_aggregation.R
Created Oct 3, 2019
Convex Dirichlet Aggregation with brms and Parsnip
View convex_aggregation.R
## 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) {