agentsclimarketplace

Run2 optimized dbscan

Skill cxcscmu/SkillLearnBench/skills/b2-self-feedback-gemini-3-flash-preview/dbscan-parameter-tuning/run2_optimized-dbscan

Efficient DBSCAN implementation by caching distance matrices for repeated hyperparameter evaluations.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run2_optimized-dbscan

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

SKILL.md

1.3 KB, 281 tokens by cl100k_base, as published. Nobody here has run it

Optimized DBSCAN for Grid Search

When performing grid search over eps and min_samples while keeping the distance metric (and its parameters like shape_weight) constant, it is much faster to precompute the distance matrix once.

Caching Strategy

import numpy as np
from sklearn.cluster import DBSCAN

def precompute_distances(points, w):
    """Precompute distance matrix for a specific shape_weight."""
    x, y = points[:, 0], points[:, 1]
    dx = x[:, np.newaxis] - x[np.newaxis, :]
    dy = y[:, np.newaxis] - y[np.newaxis, :]
    return np.sqrt((w * dx)**2 + ((2 - w) * dy)**2)

def cluster_with_precomputed(dist_matrix, points, eps, min_samples):
    """Cluster using precomputed distances and return centroids."""
    if len(points) < min_samples:
        return np.array([])
    
    db = DBSCAN(eps=eps, min_samples=min_samples, metric='precomputed')
    labels = db.fit_predict(dist_matrix)
    
    unique_labels = set(labels) - {-1}
    if not unique_labels:
        return np.array([])
    
    centroids = [np.mean(points[labels == l], axis=0) for l in unique_labels]
    return np.array(centroids)

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.