Skip to content

Instantly share code, notes, and snippets.

View alexhallam's full-sized avatar
🚀
Launching Code

Alex Hallam alexhallam

🚀
Launching Code
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 17 columns, instead of 9. in line 4.
z,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16
-1.938505597784832,1,-6.906754778648554,3.446470634545628,-0.499,0.249001,-1.7197888466382685,-0.124251499,0.858174634472496,0.062001498001,-0.4282291426017755,-0.030938747502499,0.21368634215828597,0.015438435003747,-0.1066294847369847,-0.00770377906686975,0.05320811288375537
-1.794850245335927,1,-6.212606095751519,3.0938778356842564,-0.498,0.248004,-1.5407511621707597,-0.123505992,0.7672940787610383,0.061505984016,-0.3821124512229971,-0.030629980039968,0.19029200070905253,0.01525373005990406,-0.09476541635310816,-0.00759635756983222,0.04719317734384787
-1.6050353229159695,1,-5.806138481293728,2.885650825202983,-0.497,0.247009,-1.4341684601258826,-0.122763473,0.7127817246825636,0.061013446081,-0.3542525171672341,-0.030323682702257,0.17606350103211535,0.01507087030302173,-0.08750356001296133,-0.00749022254060179,0.04348926932644178
-1.525355535852145,1,-5.517452896464707,2.736656636646495,-0.496,0.246016,-1.3573816917766617,-0.122023936,0.67326131912122
use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};
use std::cmp::min;
use tempfile::tempdir;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[tokio::main]
async fn download_data(url_path: &str) {
let dir = tempdir().unwrap();
let file_path = dir.path().join("tmp_file");
@alexhallam
alexhallam / walmart_ca_food.csv
Last active November 22, 2022 19:57
walmart_food
id ds y
001 2011-01-29 1.0
005 2011-01-29 1.0
011 2011-01-29 3.0
014 2011-01-29 11.0
015 2011-01-29 5.0
001 2011-01-30 1.0
005 2011-01-30 0.0
011 2011-01-30 2.0
014 2011-01-30 0.0
@alexhallam
alexhallam / screen_rec
Last active October 18, 2022 00:06
ffmpeg screen recording
ffmpeg -video_size 2560x1440 -framerate 60 -f x11grab -i :1 Videos/data_leaking.mkv
theme_set(theme_538)
palette = ["#000000", "#ee1d52"]
df_actuals_forecasts_n = pd.concat([df_WALMART, 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("")
n = tbsp.Snaive()
df_n = (n.predict(df_WALMART, horizon=7*4, frequency="D", lag = 7, uncertainty_samples = 1000).assign(model = 'snaive'))
df_n.head(14)
import pandas as pd
import tablespoon as tbsp
from tablespoon.data import WALMART
from mizani.breaks import date_breaks
from plotnine import *
from datetime import datetime
# make date string a date object
df_WALMART = WALMART
import pandas as pd
import tablespoon as tbsp
from tablespoon.data import WALMART
from mizani.breaks import date_breaks
from plotnine import *
from datetime import datetime
# make date string a date object
df_WALMART = WALMART
@alexhallam
alexhallam / full_tbsp.py
Created May 28, 2022 17:35
tablespoon naive
import pandas as pd
import tablespoon as tbsp
from tablespoon.data import APPL
from tablespoon.data import SEAS
from mizani.breaks import date_breaks
from plotnine import *
from datetime import datetime
# make date string a date object
@alexhallam
alexhallam / seas_plot.py
Created May 28, 2022 17:25
seasonal plot
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"))