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
theme_set(theme_538) | |
palette = ["#000000", "#ee1d52"] | |
df_SEAS = SEAS | |
df_SEAS = df_SEAS.assign(ds = lambda df: pd.to_datetime(df.ds)) | |
df_actuals_forecasts_n = pd.concat([df_SEAS, df_sn]) | |
p = ( | |
ggplot(df_actuals_forecasts_n, aes(x="ds", y="y")) | |
+ geom_line(aes(y = 'y'), color = palette[0]) | |
+ geom_point(aes(y = 'y_sim'), color = palette[1], size = 0.1, alpha = 0.1) | |
+ scale_x_datetime(breaks=date_breaks("1 week")) |
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 tablespoon as tbsp | |
from tablespoon.data import SEAS | |
sn = tbsp.Snaive() | |
df_sn = sn.predict( | |
SEAS, horizon=7 * 4, frequency="D", lag=7, uncertainty_samples=800 | |
).assign(model="snaive") | |
df_sn.head(10) |
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
theme_set(theme_538) | |
palette = ["#000000", "#ee1d52"] | |
df_actuals_forecasts_n = pd.concat([df_APPLE, df_n]) | |
p = ( | |
ggplot(df_actuals_forecasts_n, aes(x="ds", y="y")) | |
+ geom_line(aes(y = 'y'), color = palette[0]) | |
+ geom_point(aes(y = 'y_sim'), color = palette[1], size = 0.1, alpha = 0.1) | |
+ scale_x_datetime(breaks=date_breaks("1 month")) | |
+ theme(axis_text_x=element_text(angle=45)) | |
+ xlab("") |
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
n = tbsp.Naive() | |
df_n = (n.predict(df_APPLE, horizon=7*4, frequency="D", lag = 1, uncertainty_samples = 500).assign(model = 'naive')) | |
df_n.head() |
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 pandas as pd | |
import tablespoon as tbsp | |
from tablespoon.data import APPL | |
from mizani.breaks import date_breaks | |
from plotnine import * | |
from datetime import datetime | |
# make date string a date object | |
df_APPLE = APPL |
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 torch | |
import torch.nn as nn | |
import numpy as np | |
from sklearn import datasets | |
import matplotlib.pyplot as plt | |
from torch.distributions.normal import Normal | |
from torch.distributions.uniform import Uniform | |
from pprint import pprint | |
# 0) Prepare data | |
X_numpy, y_numpy = datasets.make_regression(n_samples=100, n_features=1, noise=20, random_state=4) |
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 | |
font = { | |
"A": np.array( | |
[ | |
[0, 0, 1, 0, 0], | |
[0, 1, 0, 1, 0], | |
[1, 0, 0, 0, 1], | |
[1, 0, 0, 0, 1], |
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 | |
from itertools import product | |
from multiprocessing import Pool | |
def smash(a_tuple): | |
""" | |
smash some strings and numbers together and return final string | |
""" | |
return a_tuple[0] + str(a_tuple[1]) + a_tuple[2] + str(a_tuple[3]) |
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
use directories::{BaseDirs}; | |
use std::fs::{create_dir}; | |
fn main() { | |
if let Some(base_dirs) = BaseDirs::new() { | |
let config_path = base_dirs.config_dir(); | |
let more_path = create_dir(config_path + "/some/dir").unwrap(); | |
println!("{:?}",base_dirs.config_dir()); | |
// Linux: $XDG_CONFIG_HOME or $HOME/.config | |
// Windows: {FOLDERID_RoamingAppData} |
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
# calculate the sum of a, b, b2 | |
n <- 1000 | |
m <- 10 | |
a <- rnorm(n, 10) | |
b <- rnorm(n, 20) | |
b2 <- .1*a + .1*b | |
c <- sample(a, size = m*n, replace=T) + sample(b, size = m*n, replace=T) + sample(b2, size = m*n, replace=T) |