Search for a command to run...
π² Beyond Proximity: Spatially Anisotropic Demand Dependencies in Urban Bike-Sharing Weather-Augmented ConvLSTM Analysis of Washington DC Capital Bikeshare Β· January 2026 π Overview This repository contains the full implementation of a spatially-adapted permutation-based dependency analysis framework for urban bike-sharing demand, applied to Washington DC Capital Bikeshare trip data from January 2026. It accompanies the paper: "Beyond Proximity: Spatial Dependency in Washington DC Bike-Sharing β Weather-Augmented ConvLSTM Evidence"Findings Journal β Transport Research (Submitted 2026) The core question: do spatial dependencies in bike-sharing demand follow geographic proximity, or are they governed by functional urban linkages? We answer this by training ConvLSTM models for member and casual users separately, augmenting them with real weather data, and computing a 64Γ64 permutation-based spatial dependency matrix Ξ¦ for each user type. π― Aim & Scope Study area Washington DC, USA Data source Capital Bikeshare Open Data Period January 2026 (251,633 trips) Spatial resolution 8Γ8 regular grid (64 cells, β1,500 m each) Temporal resolution 30-minute intervals User types Member (205,329 trips) and Casual (46,304 trips) Weather source Open-Meteo Historical Archive API What this project establishes: Whether spatial influence in bike-sharing conforms to the geographic proximity assumption How member and casual users differ in their spatial dependency structures Whether weather augmentation improves winter demand prediction beyond spatiotemporal models alone A replication and extension of Miao et al. (2025) from NYC to a structurally distinct city π¬ Key Findings Metric Member Casual RΒ² 0.816 0.427 MAE (pickups/cell/interval) 0.292 0.112 Mean Ξ¦ dependency 0.00819 0.00148 Max single-pair Ξ¦ 2.632 (cell 36β35) 0.494 Proximityβdep. correlation β0.164 β0.131 Anisotropy index 2.749 2.550 Member / Casual Ξ¦ ratio 5.52Γ β π Spatial influence does NOT follow geographic proximity. Dependencies are anisotropic, sparse, and concentrated in a downtown core cluster (cells 28, 29, 36, 37 β the GeorgetownβDowntownβCapitol Hill corridor). Members exhibit 5.52Γ stronger inter-cell dependencies than casual users. ποΈ Repository Structure π¦ bikeshare-spatial-dependency β£ π bikeshare_spatial_dependency.ipynb β Main Colab notebook (run this) β£ π README.md β This file β£ π requirements.txt β Python dependencies β£ π outputs/ β Generated figures and results β β£ πΌοΈ activity_distribution.png β β£ πΌοΈ spatial_dependencies_member.png β β£ πΌοΈ spatial_dependencies_casual.png β β£ πΌοΈ user_type_comparison.png β β£ πΌοΈ training_history_member.png β β£ πΌοΈ training_history_casual.png β β£ πΌοΈ predictions_member.png β β£ πΌοΈ predictions_casual.png β β£ πΌοΈ grid_layout.png β β£ πΊοΈ spatial_map_member.html β β£ πΊοΈ spatial_map_casual.html β β£ π’ phi_matrix_member.npy β β£ π’ phi_matrix_casual.npy β β£ π spatial_influence_analysis.csv β β π summary_statistics.txt β π references_bikeshare.bib β BibTeX references βοΈ How the Script Works The pipeline runs in 18 sequential cells in Google Colab: DATA FEATURES MODEL ANALYSIS β β β β βΌ βΌ βΌ βΌ Capital Weather API ConvLSTM Permutation Bikeshare βββΊ (Open-Meteo) βββΊ (3 layers) βββΊ Dependency Trip CSV + Temporal + Dense Matrix Ξ¦ Features Branch (64Γ64 per (7 inputs) Separate user type) Member/Casual Cell-by-cell breakdown Cell Name Description 1 Install Installs TensorFlow, SHAP, Folium, GeoPandas, Plotly 2 Imports Loads all libraries and sets random seeds (42) 3 Config Defines study area bbox, grid size (8Γ8), time interval (30 min), model hyperparameters 4 Data Extraction Extracts 202601-capitalbikeshare-tripdata.zip to CSV 5 Load & Clean Parses timestamps, removes invalid trips, filters to study area bbox 6 Weather Data Fetches hourly temperature, precipitation, wind speed, humidity from Open-Meteo API for DC (38.9Β°N, 77.03Β°W); falls back to synthetic Jan DC weather if API unavailable 7 Grid Creation Creates 8Γ8 regular lat/lon grid; assigns each trip a start and end cell ID 8 Aggregation Aggregates pickups/dropoffs per cell per 30-min interval, split by member/casual 9 Sequence Prep Builds 4-step lookback spatiotemporal tensors + 7-feature external vectors for each user type 10 Model Build Constructs dual-input ConvLSTM: spatial branch (3 Γ ConvLSTM2D, 64 filters) + external dense branch (32β64 units), merged and output via 1Γ1 Conv 11 Training Trains member and casual models with Adam (lr=0.001), MSE loss, early stopping (patience=10), LR reduction on plateau; 80/20 temporal split 12 Ξ¦ Matrix For each of 64Γ63=4,032 sourceβtarget cell pairs: zeros out source cell history in 30 sampled test sequences, measures mean absolute change in target predictions β Ξ¦(srcβtgt) 13 Dependency Viz Plots 64Γ64 Ξ¦ heatmap + net influence map with top-10 dependency arrows 14 Interactive Map Generates Folium maps coloured by net spatial influence per cell 15 User Comparison Side-by-side analysis: distribution histograms, proximity scatter, outward influence grids 16 Predictions Visualises actual vs predicted pickup grids for 4 random test samples per user type 17 Summary Prints all key statistics: RΒ², MAE, anisotropy index, proximity correlation, dependency ratio 18 Export Saves all outputs: .npy matrices, .csv, .png figures, .html maps π Quick Start Option A β Google Colab (Recommended) Click the Open in Colab badge above Upload 202601-capitalbikeshare-tripdata.zip to /content/ when prompted in Cell 4 Run all cells: Runtime β Run all Download outputs from /content/outputs/ Option B β Local Setup # Clone the repo git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git cd YOUR_REPO # Install dependencies pip install -r requirements.txt # Download data from Capital Bikeshare # https://capitalbikeshare.com/system-data β January 2026 # Place the zip in the project root # Launch Jupyter jupyter notebook bikeshare_spatial_dependency.ipynb requirements.txt tensorflow>=2.12 shap>=0.42 pandas>=2.0 numpy>=1.24 scikit-learn>=1.3 matplotlib>=3.7 seaborn>=0.12 folium>=0.14 geopandas>=0.13 requests>=2.31 plotly>=5.15 π Selected Output Figures Activity DistributionMember vs. Casual pickup heatmaps Member Dependency Matrix Ξ¦64Γ64 permutation-based influence User Type ComparisonDependency distributions + proximity scatter Training ConvergenceMSE and MAE curves for both models All figures are saved to /content/outputs/ at 300 DPI during runtime. π§ Model Architecture Spatial Input External Input [batch, 4, 8, 8, 2] [batch, 7] β β ConvLSTM2D (64) Dense (32, ReLU) BatchNorm + Dropout(0.2) BatchNorm β Dense (64, ReLU) ConvLSTM2D (64) β BatchNorm + Dropout(0.2) Reshape (1,1,64) β UpSampling2D (8Γ8) ConvLSTM2D (64) β BatchNorm β ββββββββββββ¬βββββββββββββββββββββ β Concatenate β Conv2D(2, 1Γ1, ReLU) β Output [batch, 8, 8, 2] (pickups + dropoffs) Training configuration: Optimizer: Adam (lr = 0.001, reduce on plateau: factor 0.5, patience 5) Loss: Mean Squared Error Early stopping: patience = 10, restore best weights Batch size: 32 | Max epochs: 30 | Split: 80/20 temporal π Spatial Dependency Method The Ξ¦ matrix is computed via permutation-based perturbation β a model-agnostic alternative to gradient-based SHAP: for each (source_cell, target_cell) pair: 1. Take 30 random test sequences 2. Zero out source_cell values in the lookback window 3. Re-run model inference 4. Ξ¦(source β target) = mean |baseline_pred - perturbed_pred| This yields a 64Γ64 directed influence matrix per user type. Key derived metrics: Outward influence: column sum of Ξ¦ β how much a cell drives others Inward influence: row sum of Ξ¦ β how much a cell is driven by others Net influence: outward β inward Anisotropy index: CV of column-wise outward sums Proximity correlation: Pearson r(grid distance, Ξ¦)