Agent skill

Custom Distance Metrics

by benchflow-ai in benchflow-ai/skillsbench

Define custom distance/similarity metrics for clustering and ML algorithms.

Apache-2.0Auto-check passedData & Analytics

Install Custom Distance Metrics

skills CLI
$ npx skills add benchflow-ai/skillsbench --skill custom-distance-metrics -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install benchflow-ai/skillsbench custom-distance-metrics --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/benchflow-ai/skillsbench.git skills-src && mkdir -p .claude/skills && cp -r skills-src/tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics .claude/skills/custom-distance-metrics && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
custom-distance-metrics
GitHub stars
1.8k
Token cost
~674 tokens
SKILL.md length
99 words
Files
1
Skills in repo
189
Repo updated
First seen
Licence
Apache-2.0

At a glance

Define custom distance/similarity metrics for clustering and ML algorithms.

  • Working with DBSCAN
  • SKILL.md covers Defining Custom Metrics for…, Parameterized Distance Functions, Example: Manhattan Distance… and Using scipy.spatial.distance, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Scipy distance functions with application-specific metrics

What it does

Custom Distance Metrics is an agent skill from benchflow-ai/skillsbench. Define custom distance/similarity metrics for clustering and ML algorithms. Use when working with DBSCAN, sklearn, or scipy distance functions with application-specific metrics.

Its SKILL.md is about 670 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Data & Analytics, covering Machine learning. It works with scikit-learn. The repository describes itself as: SkillsBench evaluates how well skills work and how effective agents are at using them. The licence is Apache-2.0.

When your agent uses it

  • Working with DBSCAN
  • Scipy distance functions with application-specific metrics

Example prompts

  • “/custom-distance-metrics”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 9a1f4dd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Custom Distance Metrics loads about 674 tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 99 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~674

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from benchflow-ai/skillsbench at commit 9a1f4dd, republished under its Apache-2.0 licence (© benchflow-ai). 99 words, ~674 tokens.

Download SKILL.mdSave it as .claude/skills/custom-distance-metrics/SKILL.md (or your agent's skills folder).
name
custom-distance-metrics
description
Define custom distance/similarity metrics for clustering and ML algorithms. Use when working with DBSCAN, sklearn, or scipy distance functions with application-specific metrics.

Custom Distance Metrics

Custom distance metrics allow you to define application-specific notions of similarity or distance between data points.

Defining Custom Metrics for sklearn

sklearn's DBSCAN accepts a callable as the metric parameter:

python
from sklearn.cluster import DBSCAN

def my_distance(point_a, point_b):
    """Custom distance between two points."""
    # point_a and point_b are 1D arrays
    return some_calculation(point_a, point_b)

db = DBSCAN(eps=5, min_samples=3, metric=my_distance)

Parameterized Distance Functions

To use a distance function with configurable parameters, use a closure or factory function:

python
def create_weighted_distance(weight_x, weight_y):
    """Create a distance function with specific weights."""
    def distance(a, b):
        dx = a[0] - b[0]
        dy = a[1] - b[1]
        return np.sqrt((weight_x * dx)**2 + (weight_y * dy)**2)
    return distance

# Create distances with different weights
dist_equal = create_weighted_distance(1.0, 1.0)
dist_x_heavy = create_weighted_distance(2.0, 0.5)

# Use with DBSCAN
db = DBSCAN(eps=10, min_samples=3, metric=dist_x_heavy)

Example: Manhattan Distance with Parameter

As an example, Manhattan distance (L1 norm) can be parameterized with a scale factor:

python
def create_manhattan_distance(scale=1.0):
    """
    Manhattan distance with optional scaling.
    Measures distance as sum of absolute differences.
    This is just one example - you can design custom metrics for your specific needs.
    """
    def distance(a, b):
        return scale * (abs(a[0] - b[0]) + abs(a[1] - b[1]))
    return distance

# Use with DBSCAN
manhattan_metric = create_manhattan_distance(scale=1.5)
db = DBSCAN(eps=10, min_samples=3, metric=manhattan_metric)

Using scipy.spatial.distance

For computing distance matrices efficiently:

python
from scipy.spatial.distance import cdist, pdist, squareform

# Custom distance for cdist
def custom_metric(u, v):
    return np.sqrt(np.sum((u - v)**2))

# Distance matrix between two sets of points
dist_matrix = cdist(points_a, points_b, metric=custom_metric)

# Pairwise distances within one set
pairwise = pdist(points, metric=custom_metric)
dist_matrix = squareform(pairwise)

Performance Considerations

  • Custom Python functions are slower than built-in metrics
  • For large datasets, consider vectorizing operations
  • Pre-compute distance matrices when doing multiple lookups

© benchflow-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics of benchflow-ai/skillsbench.

Open the folder on GitHubat commit 9a1f4dd

Compare with similar skills

Custom Distance Metrics next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Custom Distance Metrics compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Custom Distance Metrics this skillbenchflow-ai/skillsbench1.8k—~674Automated safety check: PassApache-2.0
Scikit LearnzLanqing/codex-claude-academic-skills4.7k16 repos~3.9kAutomated safety check: PassBSD-3-Clause
Senior Data ScientistRaidriar7170/hermes-skilleval1255 repos~1.4kAutomated safety check: PassMIT
Time Series Analytics Useropen-edge-platform/edge-ai-libraries171—~3.1kAutomated safety check: PassApache-2.0
Estimate Online Covariancemicroprediction/precise337—~535Automated safety check: PassMIT
Precisemicroprediction/precise337—~782Automated safety check: PassMIT

Similar skills

  • Scikit Learn

    zLanqing/codex-claude-academic-skills

    Machine learning in Python with scikit-learn. An agent skill from zLanqing/codex-claude-academic-skills.

    4.7k GitHub starsUsed in 16 repos~3.9k tokens
    Data & AnalyticsAuto-check passed
  • Senior Data Scientist

    Raidriar7170/hermes-skilleval

    World-class data science skill for statistical modeling, experimentation, causal inference, and advanced analytics.

    125 GitHub starsUsed in 5 repos~1.4k tokens
    Data & AnalyticsAuto-check passed
  • Time Series Analytics User

    open-edge-platform/edge-ai-libraries

    Build a new time-series analytics use case on top of the deployed Time Series Analytics microservice — bring it up with Docker Compose (from a repo clone, or by fetching the compose files from…

    171 GitHub stars~3.1k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Estimate Online Covariance

    microprediction/precise

    Estimate a covariance / correlation / precision matrix incrementally with precise.

    337 GitHub stars~535 tokensUpdated 5 days ago
    Data & AnalyticsAuto-check passed
  • Precise

    microprediction/precise

    Online (incremental) covariance, correlation, and precision estimation in Python — the streaming complement to sklearn.covariance.

    337 GitHub stars~782 tokensUpdated 5 days ago
    Data & AnalyticsAuto-check passed
  • Aeon Time Series Machine Learning

    davila7/claude-code-templates

    Guides time series machine learning with the aeon toolkit: classification, regression, clustering, forecasting, anomaly detection, segmentation and similarity search.

    33k GitHub starsUsed in 13 repos~2.6k tokens
    Data & AnalyticsAuto-check passed

More from benchflow-ai/skillsbench

All 189 skills in this repo
  • Lean4 Memories

    benchflow-ai/skillsbench

    This skill should be used when working on Lean 4 formalization projects to maintain persistent memory of successful proof patterns, failed approaches, project conventions, and user preferences…

    1.8k GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Senior Data Engineer

    benchflow-ai/skillsbench

    World-class data engineering skill for building scalable data pipelines, ETL/ELT systems, real-time streaming, and data infrastructure.

    1.8k GitHub stars~5.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Ac Branch Pi Model

    benchflow-ai/skillsbench

    AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching acopf-math-model.md and MATPOWER branch fields.

    1.8k GitHub stars~1.1k tokensUpdated 2 mo ago
    Auto-check passed
  • Civ6lib

    benchflow-ai/skillsbench

    Civilization 6 district mechanics library. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~1.7k tokensUpdated 2 mo ago
    Auto-check passed
  • D3 Visualization

    benchflow-ai/skillsbench

    Build deterministic, verifiable data visualizations with D3.js (v6).

    1.8k GitHub stars~1.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Dc Power Flow

    benchflow-ai/skillsbench

    DC power flow analysis for power systems. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~717 tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Custom Distance Metrics

What does Custom Distance Metrics do?

Define custom distance/similarity metrics for clustering and ML algorithms. Custom Distance Metrics is an agent skill from benchflow-ai/skillsbench. Define custom distance/similarity metrics for clustering and ML algorithms.

When should I use Custom Distance Metrics?

Custom Distance Metrics fits situations like: working with DBSCAN; scipy distance functions with application-specific metrics.

How do I install Custom Distance Metrics in Claude Code?

Run `npx skills add benchflow-ai/skillsbench --skill custom-distance-metrics -a claude-code`. Or copy the skill folder (tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics in benchflow-ai/skillsbench) into .claude/skills/custom-distance-metrics in your project. Claude Code loads it when a task matches its description.

How do I install Custom Distance Metrics in Codex?

Run `npx skills add benchflow-ai/skillsbench --skill custom-distance-metrics -a codex`. Or copy the skill folder (tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics in benchflow-ai/skillsbench) into .agents/skills/custom-distance-metrics in your project. Codex loads it when a task matches its description.

Can I use Custom Distance Metrics in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add benchflow-ai/skillsbench --skill custom-distance-metrics -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/custom-distance-metrics, .gemini/skills/custom-distance-metrics, .github/skills/custom-distance-metrics and .opencode/skills/custom-distance-metrics in your project.

What does Custom Distance Metrics need to run?

SKILL.md names no scripts, command-line tools or credentials: Custom Distance Metrics is instructions for the agent only. Our summary lists: Python 3.

Does Custom Distance Metrics access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Custom Distance Metrics safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Custom Distance Metrics use?

Custom Distance Metrics is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Custom Distance Metrics use?

About 674 tokens (SKILL.md is roughly 2.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Custom Distance Metrics?

Skills that share tags, products or a category with Custom Distance Metrics: Scikit Learn (zLanqing/codex-claude-academic-skills, 4.7k stars), Senior Data Scientist (Raidriar7170/hermes-skilleval, 125 stars), Time Series Analytics User (open-edge-platform/edge-ai-libraries, 171 stars) and Estimate Online Covariance (microprediction/precise, 337 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Custom Distance Metrics?

benchflow-ai (a GitHub organization) maintains it in benchflow-ai/skillsbench, which has 1,835 GitHub stars. The repository holds 189 skills in this directory. The repository was last updated on July 23, 2026.

Source: benchflow-ai/skillsbench on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.