Skip to content

Instantly share code, notes, and snippets.

View natesheehan's full-sized avatar
👽

Nathanael Sheehan natesheehan

👽
View GitHub Profile
# Aim: generate scenarios for new developments
library(tidyverse)
library(sf)
library(stplanr)
# set-up and parameters ---------------------------------------------------
# setwd("~/cyipt/actdev") # run this script from the actdev folder
if(!exists("site_name")) { # assume all presets loaded if site_name exists
####
####
#### AIM: Use PCT data to create scenario of change where commuting cycling levels increase and car journeys decrease which can be imported
#### into A/B Street city simulation software. This method should be fully reproducible for other pct_regions.
####
####
#### LIBRARYS ####
library(pct)
library(sf)
## You need a valid access token from Mapbox
key = mapbox_token
set_token( key )
places = tibble::tribble(
~name, ~o_x, ~o_y, ~d_x, ~d_y,
"Home", -1.524, 53.819, -1.552, 53.807,
"Work", -1.552, 53.807, -1.560, 53.812,
"Park", -1.560, 53.812, -1.556, 53.802,
"Cafe", -1.556, 53.802, -1.524, 53.819
library(osrm)
library(stplanr)
library(sf)
places = tibble::tribble(
~name, ~x, ~y,
"Home", -1.524, 53.819,
"Work", -1.552, 53.807,
"Park", -1.560, 53.812,
"Cafe", -1.556, 53.802
# activation function
# sigmoid
sigmoid <- function(x) return(1/(1+exp(-x)))
d.sigmoid <- function(x) return(x*(1-x))
# neural net function with 1 hidden layer - user specifies number of nodes
nn <- function(X, y, hl, niters, learning.rate){
# add in intercept
X <- cbind(rep(1, nrow(X)), X)
Archimedian_Spiral = function(seq_start, seq_end, seq_space, bg, color) {
t = seq(seq_start, seq_end, by = seq_space) # set
# create points
x = t * cos(t) # moves the centrepoiunt of the spiral outward from the origin
y = t * sin(t) # controls the distance between loops
#bg color
par(bg = bg)
# Plot spiral
plot(
x,
import pandas as pd
import matplotlib.pyplot as plt
# Load the CSV file
file_path = 'Interviews-Aggregated - Sheet1 (2).csv' # Make sure to update this path
data = pd.read_csv(file_path)
# Clean the `Theme` column
data['Theme'] = data['Theme'].str.strip() # Trim whitespace
data = data[data['Theme'] != ''] # Remove rows where `Theme` is blank
import torch
import torch.nn as nn
from torch.nn import functional as F
# hyperparameters
batch_size = 64 # how many independent sequences will we process in parallel?
block_size = 256 # what is the maximum context length for predictions?
max_iters = 5000
eval_interval = 500
learning_rate = 3e-4