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 scipy.stats | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
fig, ax = plt.subplots(figsize=(14, 8)) | |
sns.kdeplot(scipy.stats.beta(292 + 1, 1000 - 292 + 1).rvs(1000), ax=ax) |
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 ast | |
from ast import NodeVisitor | |
import subprocess | |
class Visitor(NodeVisitor): | |
def __init__(self, file) -> None: | |
self.file = file | |
def visit_Call(self, node: ast.Call) -> None: | |
if ( |
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 ast | |
import os | |
from ast import NodeVisitor | |
import subprocess | |
class Visitor(NodeVisitor): | |
def __init__(self, file) -> None: | |
self.file = file | |
def visit_FunctionDef(self, node: ast.FunctionDef) -> None: |
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 functools | |
import jax | |
import jax.numpy as jnp | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import numpyro.distributions as dist | |
import pandas as pd | |
import seaborn as sns | |
from matplotlib import patches |
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
samples = distribution.sample(rng_key, sample_shape=(1000,)) | |
pushforward_samples = jax.vmap(g)(samples) |
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
def inv_g(x_tilde): | |
"""Inverse of `g`.""" | |
return jnp.asarray([jax.scipy.special.logit(x_tilde[0]), jnp.log(x_tilde[1])]) | |
x_tilde = jnp.column_stack( | |
[jnp.linspace(0.001, 0.999, 1000), jnp.linspace(0.001, 3, 1000)] | |
) | |
pre_x_tilde = jax.vmap(inv_g)(x_tilde) |
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
fig, axes = plt.subplots(nrows=1, ncols=2, sharex=False, sharey=False) | |
axes = axes.flatten() | |
data = pd.DataFrame(samples, columns=["x_0", "x_1"]) | |
sns.kdeplot(data=data, x="x_0", y="x_1", ax=axes[0]) | |
data = pd.DataFrame(pushforward_samples, columns=["x_tilde_0", "x_tilde_1"]) | |
sns.kdeplot(data=data, x="x_tilde_0", y="x_tilde_1", ax=axes[1]) | |
xyA = [2.5, -0.6] |
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 numpy as np | |
import pandas as pd | |
from lightgbm import LGBMRegressor, log_evaluation | |
from sklearn.datasets import load_breast_cancer | |
from sklearn.metrics import mean_absolute_error | |
from sklearn.model_selection import KFold | |
data = load_breast_cancer() | |
X = pd.DataFrame(data.data, columns=data.feature_names) | |
y = pd.Series(data.target) |
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 bornly as bns | |
import numpy as np | |
import pandas as pd | |
from pmdarima import auto_arima | |
from statsmodels.tsa.statespace.sarimax import SARIMAX | |
flights = bns.load_dataset("flights") | |
flights["t"] = np.arange(len(flights)) | |
PERIOD = 12 | |
n_steps = 12 |
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 sys | |
import subprocess | |
import re | |
import shlex | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('command') | |
parser.add_argument('action', choices=['pull', 'push']) | |
args = parser.parse_args() |