Skip to content

Instantly share code, notes, and snippets.

View plot_timeseries.py
def plot_timeseries(filenames: list):
""" Plot a list of timeseries CSVs to a single graph """
combined_df = pd.DataFrame()
for filename in filenames:
df = pd.read_csv(filename)
df['date'] = pd.to_datetime(df['date'])
df['label'] = filename
combined_df = pd.concat([combined_df, df])
View generate_datasets.py
# Use the model to generate synthetic datasets
seed_data = json.loads(trends_df[seed_fields].to_json(orient="records"))
for dataset in range(5):
model.generate(max_invalid=1e5,
num_proc=1, # disable paralellism when using seed data
seed_fields=seed_data)
df = restore_daily(model.get_synthetic_df(), start, trend_col)
df.to_csv(f'synthetic-data-{dataset}.csv', index=False)
View synthetics_config.py
# Create the Gretel Synthtetics Training / Model Configuration
from pathlib import Path
from gretel_helpers.synthetics import create_df, SyntheticDataBundle
config_template = {
"epochs": 50,
"early_stopping": False,
"vocab_size": 20,
"reset_states": False,
View extract_trends.py
View sin_timeseries.py
# Load and preview dataset
import datetime
import pandas as pd
import numpy as np
day = 24 * 60 * 60
year = 365.2425 * day
def load_dataframe() -> pd.DataFrame:
@zredlined
zredlined / setup_tensorflow_gpu.sh
Last active May 7, 2021
Install TensorFlow 2.4 with GPU support
View setup_tensorflow_gpu.sh
#!/bin/bash
# Initialize conda environment
echo 'Create Conda env? Type y or n and then press [ENTER]:'
read create_env
if [ $create_env = "y" ];
then
echo "Provide name for Conda virtualenv and then press [ENTER]:"
read env_name
View setup-gretel-synthetics-tensorflow24-with-gpu.sh
#!/bin/bash
# Initialize conda environment
echo 'Create Conda env? Type y or n and then press [ENTER]:'
read create_env
if [ $create_env = "y" ];
then
echo "Provide name for Conda virtualenv and then press [ENTER]:"
read env_name
@zredlined
zredlined / aws_lambda_sns_update_mailchimp.py
Created Jan 7, 2021
Barebones AWS Lambda code to update a user's tags in Mailchimp
View aws_lambda_sns_update_mailchimp.py
import json
import hashlib
import urllib3
API_KEY = "[API-KEY]"
DC = "us19"
LIST_ID = "[AUDIENCE]"
TAG = 'core'
http = urllib3.PoolManager()
@zredlined
zredlined / bike-orders.json
Created Dec 15, 2020
bike-orders.json - open dataset that's useful for benchmarking and testing tabular NER. 100 records.
View bike-orders.json
[
{
"CustomerID": 26159,
"Title": null,
"FirstName": "Virginia",
"MiddleName": null,
"LastName": "Raman",
"Suffix": null,
"AddressLine1": "3242 Coralie Drive",
"AddressLine2": null,
@zredlined
zredlined / setup-tensorflow-gpu-ubuntu-18_04.sh
Created Sep 25, 2020
Shell script to setup NVIDIA GPU acceleration on TensorFlow with Ubuntu 18.04 and CUDA 10.1
View setup-tensorflow-gpu-ubuntu-18_04.sh
# Shell script to setup GPU acceleration for TensorFlow on Ubuntu 18.04
# Tested on a default Ubuntu 18.04 VM image in Google Compute
# Install CUDA
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda