Dbscan custom metric
Implements DBSCAN with a weighted Euclidean distance metric.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill dbscan-custom-metricAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.6 KB, 141 tokens by cl100k_base, as published. Nobody here has run it
Usage
Use this for clustering problems where directional features need attenuation.
import numpy as np
from sklearn.cluster import DBSCAN
from sklearn.metrics import pairwise_distances
def custom_distance(a, b, w):
# d(a, b) = sqrt((w * Δx)² + ((2 - w) * Δy)²)
dx = (a[0] - b[0]) * w
dy = (a[1] - b[1]) * (2 - w)
return np.sqrt(dx**2 + dy**2)
# For DBSCAN:
# Construct a custom distance matrix or pass metric='precomputed'
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.