Skip to content

Instantly share code, notes, and snippets.

View ilmonteux's full-sized avatar

ilmonteux

View GitHub Profile
@ilmonteux
ilmonteux / jet_images.ipynb
Last active June 21, 2023 15:53
Convolutional Neural Networks for jet classification - barebone pipeline
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ilmonteux
ilmonteux / segmentation_metrics.py
Last active October 24, 2024 13:19
Semantic segmentation metrics in Keras and Numpy. IoU, Dice in both soft and hard variants. Mean metrics for multiclass prediction. See https://ilmonteux.github.io/2019/05/10/segmentation-metrics.html for discussion
import numpy as np
import keras.backend as K
import tensorflow as tf
def metrics_np(y_true, y_pred, metric_name, metric_type='standard', drop_last = True, mean_per_class=False, verbose=False):
"""
Compute mean metrics of two segmentation masks, via numpy.
IoU(A,B) = |A & B| / (| A U B|)
Dice(A,B) = 2*|A & B| / (|A| + |B|)
@ilmonteux
ilmonteux / us_state_names.py
Created November 30, 2020 06:16
Name of US states and state equivalents
# from US census website (cb_2017_us_state_20m.shp, no hard-links because they keep changing them...)
us_states = ['Alaska', 'California', 'Colorado', 'District of Columbia', 'Idaho', 'Illinois', 'Iowa', 'Kentucky', 'Louisiana', 'Maryland', 'Minnesota', 'Missouri', 'New York', 'Oregon', 'Tennessee', 'Texas', 'Virginia', 'Wisconsin', 'Alabama', 'Arizona', 'Arkansas', 'Indiana', 'Kansas', 'Maine', 'Connecticut', 'Delaware', 'Georgia', 'Hawaii', 'South Carolina', 'South Dakota', 'Massachusetts', 'Michigan', 'Mississippi', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'North Carolina', 'North Dakota', 'Rhode Island', 'Ohio', 'Oklahoma', 'Pennsylvania', 'Florida', 'Montana', 'Utah', 'Vermont', 'Washington', 'West Virginia', 'Wyoming', 'Puerto Rico']