Skip to content

Instantly share code, notes, and snippets.

View larshuth's full-sized avatar

Lars Huth larshuth

  • RWTH Aachen
  • Aachen/Frankfurt
  • LinkedIn in/huth
View GitHub Profile
@larshuth
larshuth / dunn_sklearn.py
Last active June 12, 2021 18:57
Dunn index for clusters analysis
import numpy as np
from sklearn.preprocessing import LabelEncoder
DIAMETER_METHODS = ['mean_cluster', 'farthest']
CLUSTER_DISTANCE_METHODS = ['nearest', 'farthest']
def inter_cluster_distances(labels, distances, method='nearest'):
"""Calculates the distances between the two nearest points of each cluster.