This file contains hidden or 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
ipython -i -c 'import pandas as pd; \ | |
from pandas.core.arrays import *; \ | |
import polars as pl; \ | |
from datetime import datetime, timezone, timedelta; \ | |
from pandas._libs.tslibs.parsing import guess_datetime_format; \ | |
from dateutil.parser import parse as du_parse; \ | |
import datetime as dt; \ | |
import numpy as np; \ | |
from pandas import *; \ | |
import pandas; \ |
This file contains hidden or 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
// ==UserScript== | |
// @name myshipit | |
// @author marcogorelli | |
// @match https://github.com/* | |
// adapted from https://github.com/chriskuehl/shipit/blob/master/shipit.user.js, | |
// but I removed a handful of gifs (like the pikachu one) which I didn't like | |
// ==/UserScript== | |
(function () { | |
var urls = [ |
This file contains hidden or 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
# usage: | |
# python -m cProfile -o out.prof perf.py | |
# snakeviz out.prof --server | |
import pandas as pd | |
dates = pd.date_range("1900", "2000").tz_localize("+01:00").strftime("%Y-%d-%m %H:%M:%S%z").tolist() | |
dates.append("2020-01-01 00:00:00+02:00") | |
def main(): |
This file contains hidden or 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() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |