Skip to content

Instantly share code, notes, and snippets.

View bladerun16's full-sized avatar

Claudio Sartori bladerun16

View GitHub Profile
@ramhiser
ramhiser / jaccard.py
Last active November 4, 2021 08:41
Jaccard cluster similarity in Python
import itertools
def jaccard(labels1, labels2):
"""
Computes the Jaccard similarity between two sets of clustering labels.
The value returned is between 0 and 1, inclusively. A value of 1 indicates
perfect agreement between two clustering algorithms, whereas a value of 0
indicates no agreement. For details on the Jaccard index, see:
http://en.wikipedia.org/wiki/Jaccard_index
scaler = StandardScaler()
df=scaler.fit_transform(df)
kmeans_kwargs = {"init": "random","n_init": 20,"max_iter": 1000,"random_state": 1984}
cut_off=0.5
maxvars=3
kmin=2
kmax=8
cols=list(df.columns)