Skip to content

Instantly share code, notes, and snippets.

View ToucheSir's full-sized avatar

Brian Chen ToucheSir

View GitHub Profile
@ToucheSir
ToucheSir / fetch_amenities_osm.py
Created April 23, 2023 01:19
Querying amenities in Greater Victoria using OSM
import osmnx as ox
import matplotlib.pyplot as plt
from pathlib import Path
AMENITY_QUERIES = [
("bank", {"amenity": "bank"}),
("bar", {"amenity": ["bar", "pub"]}),
("coffee shop", {"amenity": "cafe", "cuisine": "coffee_shop"}),
(
@ToucheSir
ToucheSir / structintersect.jl
Created January 24, 2022 04:50
structintersect.jl
# courtesy of Mason Protter on the Julia Slack
@generated function structintersect(a::NamedTuple{a_names}, b::NamedTuple{b_names}) where {a_names, b_names}
names = Tuple(intersect(a_names, b_names))
fields = Expr(:tuple, (:(getproperty(a, $(QuoteNode(name))), getproperty(b, $(QuoteNode(name)))) for name in names)...)
quote
NamedTuple{$names}($fields)
end
end
@ToucheSir
ToucheSir / mwe.jl
Last active December 20, 2021 03:21
MWE from Flux.jl#1804
using Flux
include("weights.jl")
function gradtezt(x, weight, bias, act=selu)
gx = gpu(x)
ctc = ConvTranspose(weight, bias, act, groups=5)
gtc = gpu(ctc);
yc = Flux.withgradient(() -> sum(ctc(x)), params(ctc)) |> first
yg = Flux.withgradient(() -> sum(gtc(gx)), params(gtc)) |> first
# Classifies MNIST digits with a convolutional network.
# Writes out saved model to the file "mnist_conv.bson".
# Demonstrates basic model construction, training, saving,
# conditional early-exit, and learning rate scheduling.
#
# This model, while simple, should hit around 99% test
# accuracy after training for approximately 20 epochs.
using Flux, MLDatasets, Random, Statistics
using Flux: unsqueeze, onehotbatch, onecold, logitcrossentropy
@ToucheSir
ToucheSir / conposcovidloc.csv
Last active April 2, 2020 16:36
Ontario Covid-19 Data Exploration
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 12 columns, instead of 10 in line 5.
ACCURATE_EPISODE_DATE,Age_Group,CLIENT_GENDER,CASE_ACQUISITIONINFO,RESOLVED,Reporting_PHU,Reporting_PHU_Address,Reporting_PHU_City,Reporting_PHU_Postal_Code,Reporting_PHU_Website,Reporting_PHU_Latitude,Reporting_PHU_Longitude
2020-01-21,50s,MALE,Travel-Related,Yes,Toronto Public Health,"277 Victoria Street, 5th Floor",Toronto,M5B 1W2,www.toronto.ca/community-people/health-wellness-care/,43.65659125,-79.37935801
2020-01-22,50s,FEMALE,Travel-Related,Yes,Toronto Public Health,"277 Victoria Street, 5th Floor",Toronto,M5B 1W2,www.toronto.ca/community-people/health-wellness-care/,43.65659125,-79.37935801
2020-01-24,20s,FEMALE,Travel-Related,Yes,Middlesex-London Health Unit,50 King Street,London,N6A 5L7,www.healthunit.com,42.98146842,-81.25401572
2020-01-25,50s,MALE,Neither,Yes,Ottawa Public Health,100 Constellation Drive,Ottawa,K2G 6J8,www.ottawapublichealth.ca,45.3456651,-75.7639122
2020-02-05,20s,FEMALE,Travel-Related,Yes,Toronto Public Health,"277 Victoria Street, 5th Floor",Toronto,M5B 1W2,www.toronto.ca/commun