Skip to content

Instantly share code, notes, and snippets.

View jtrive84's full-sized avatar

James Triveri jtrive84

View GitHub Profile
@jtrive84
jtrive84 / btw.ipynb
Created April 26, 2024 20:38
Betweenness Centrality
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / saliency.ipynb
Created April 24, 2024 15:38
Saliency Maps
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / softmax.py
Created April 23, 2024 20:59
Classifier with softmax
class PreTrainedImageClassifier(nn.Module):
"""
Transfer learning using Resnet models for map image classification.
"""
def __init__(self, pt_model, dropout=0):
super().__init__()
# Set requires_grad = False for pretrained model.
for param in pt_model.parameters():
param.requires_grad = False
@jtrive84
jtrive84 / get-bounding-envelopes.ipynb
Created April 23, 2024 16:12
Get bounding envelopes for links in target region.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / segmented.ipynb
Created April 23, 2024 16:09
Segment map images
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / qgis_map_imaging.py
Created April 23, 2024 16:08
Create static map images via QGIS.
"""
Script to use for creating static map images in QGIS.
A dictionary of bounding boxes is required, with key representing the
linkId and value a list of four coordinates representing the region that
encloses the link. The dictionary for Charlotte has been included in the
repository.
Author: James D. Triveri
Date: 2024-02
"""
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jtrive84
jtrive84 / clf_eval.py
Created April 2, 2024 20:58
Classifier evaluation
import matplotlib.pyplot as plt
from sklearn.metrics import (
PrecisionRecallDisplay, precision_recall_curve, RocCurveDisplay, roc_curve,
ConfusionMatrixDisplay, confusion_matrix
)
beta = 2
prior_thresh = .50
p1, r1, thresh1 = precision_recall_curve(yactual, ypred1)
@jtrive84
jtrive84 / clf_metrics.py
Created April 2, 2024 18:12
Classifier metrics
import matplotlib.pyplot as plt
from sklearn.metrics import (
PrecisionRecallDisplay, precision_recall_curve, RocCurveDisplay, roc_curve
)
p1, r1, thresh1 = precision_recall_curve(yactual, ypred1)
p2, r2, thresh2 = precision_recall_curve(yactual, ypred2)
# Determine threshold that maximizes f1 score.