Skip to content

Instantly share code, notes, and snippets.

View charlychiu's full-sized avatar
💭
💡 🎧 🍺

charlychiu charlychiu

💭
💡 🎧 🍺
View GitHub Profile
---
apiVersion: v1
metadata:
name: gc-script
namespace: garbage-collector
kind: ConfigMap
data:
gc: |-
#!/bin/bash
@charlychiu
charlychiu / _dice.py
Created May 15, 2020 07:40 — forked from brunodoamaral/_dice.py
Dice coefficient between two boolean NumPy arrays or array-like data. This is commonly used as a set similarity measurement (though note it is not a true metric; it does not satisfy the triangle inequality). The dimensionality of the input is completely arbitrary, but `im1.shape` and `im2.shape` much be equal. This Gist is licensed under the mod…
def dice(im1, im2, empty_score=1.0):
"""
Computes the Dice coefficient, a measure of set similarity.
Parameters
----------
im1 : array-like, bool
Any array of arbitrary size. If not boolean, will be converted.
im2 : array-like, bool
Any other array of identical size. If not boolean, will be converted.
Returns