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
# Adapted from: https://stackoverflow.com/a/77261943/1316276. | |
import matplotlib | |
matplotlib.use("Agg") | |
import geodatasets | |
import geopandas as gpd | |
import glob | |
import json |
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 os | |
import torch | |
from numba import cuda, int32, njit | |
@njit((int32[:, :], int32[:, :], int32[:, :], int32[:], int32[:, :], int32[:])) | |
def loop(keys, key_mask, key2idx, cur_idx, idx2key, idx_counts): | |
for row, col in keys: |
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
# Adapted from: https://github.com/pytorch/examples/blob/main/vae/main.py. | |
import torch | |
import torch.utils.data | |
from torch import nn, optim | |
from torch.nn import functional as F | |
class VAE(nn.Module): |
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
# Heavily inspired by: https://geospatial.101workbook.org/ImportingData/ImportingImages.html. | |
import geopandas as gpd | |
import numpy as np | |
import pandas as pd | |
import requests | |
import stackstac | |
from PIL import Image | |
from satsearch import Search |
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 matplotlib.pyplot as plt | |
import math | |
import numpy as np | |
import pandas as pd | |
import sklearn.datasets | |
import time | |
import torch | |
from sklearn.linear_model import LinearRegression | |
from torch import nn, optim |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import seaborn as sns | |
N = 1000 | |
mu = 1 | |
sd = 0.1 | |
# Separate dimensions example. |
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 cv2 | |
import geopandas | |
import io | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import requests | |
import time | |
import zipfile |
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
# See: https://matheusfacure.github.io/python-causality-handbook/15-Synthetic-Control.html | |
# and: http://ftp.iza.org/dp13670.pdf. | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
from datetime import datetime, timedelta | |
from scipy.optimize import fmin_slsqp |
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
# Inspired by: https://towardsdatascience.com/the-one-pytorch-trick-which-you-should-know-2d5e9c1da2ca. | |
# Monkey patching idea suggested by @kklemon here: | |
# https://gist.github.com/airalcorn2/50ec06517ce96ecc143503e21fa6cb91?permalink_comment_id=4407423#gistcomment-4407423. | |
import torch | |
from torch import nn | |
def patch_attention(m): |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import seaborn as sns | |
csv_url = "https://raw.githubusercontent.com/gradlab/CtTrajectories/main/data/ct_dat_clean.csv" | |
df = pd.read_csv(csv_url) | |
person_ids = df["Person.ID"].unique() | |
(min_x, max_x) = (df["Date.Index"].min(), df["Date.Index"].max()) |
NewerOlder