agentsclimarketplace

Run1 dbscan custom metric

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-gemini-3.1-flash-lite-preview/dbscan-parameter-tuning/run1_dbscan-custom-metric

Implementing custom distance metrics for DBSCAN in scikit-learn for specialized coordinate-based clustering.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_dbscan-custom-metric

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

0.9 KB, 226 tokens by cl100k_base, as published. Nobody here has run it

Custom Distance Logic

Standard DBSCAN in scikit-learn accepts a metric argument. To implement the specified weighted Euclidean distance: d(a, b) = sqrt((w * Δx)² + ((2 - w) * Δy)²)

You should define a function:

import numpy as np

def get_custom_metric(w):
    def distance(u, v):
        # u and v are coordinate pairs [x, y]
        dx = (u[0] - v[0]) * w
        dy = (u[1] - v[1]) * (2 - w)
        return np.sqrt(dx**2 + dy**2)
    return distance

Pass this to the DBSCAN constructor: DBSCAN(eps=epsilon, min_samples=min_samples, metric=get_custom_metric(shape_weight)).

Note: Since metric='precomputed' is often faster for large datasets, consider pre-calculating the distance matrix if memory allows, or pass the callable directly if the dataset size per image is small.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.