Custom Distance Metrics
Define custom distance/similarity metrics for clustering and ML algorithms. Use when working with DBSCAN, sklearn, or scipy distance functions with application-specific metrics.
Install
npx skills add UCSB-NLP-Chang/Skill-Usage --skill custom-distance-metricsgit clone --depth 1 https://github.com/UCSB-NLP-Chang/Skill-Usage.git /tmp/Skill-Usage
mkdir -p ~/.claude/skills
cp -r /tmp/Skill-Usage/tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics ~/.claude/skills/custom-distance-metricsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# 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:Details
- Skill name
custom-distance-metrics- Repository
- UCSB-NLP-Chang/Skill-Usage
- Path
tasks/mars-clouds-clustering/environment/skills/custom-distance-metrics/SKILL.md- Repo updated
- 8 April 2026
FAQ
What does the Custom Distance Metrics skill do?
Define custom distance/similarity metrics for clustering and ML algorithms. Use when working with DBSCAN, sklearn, or scipy distance functions with application-specific metrics.
How do I install the Custom Distance Metrics skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add UCSB-NLP-Chang/Skill-Usage --skill custom-distance-metrics. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Custom Distance Metrics popular?
It lives in UCSB-NLP-Chang/Skill-Usage, which has 49 GitHub stars and 5 forks.
Related skills
Pubchem Database
49UCSB-NLP-Chang/Skill-Usage
Query PubChem via PUG-REST API/PubChemPy (110M+ compounds). Search by name/CID/SMILES, retrieve properties, similarity/substructure searches, bioactivity, for cheminformatics.
Pymatgen
49UCSB-NLP-Chang/Skill-Usage
Materials science toolkit. Crystal structures (CIF, POSCAR), phase diagrams, band structure, DOS, Materials Project integration, format conversion, for computational materials science.
Rdkit
49UCSB-NLP-Chang/Skill-Usage
Cheminformatics toolkit for fine-grained molecular control. SMILES/SDF parsing, descriptors (MW, LogP, TPSA), fingerprints, substructure search, 2D/3D generation, similarity, reactions. For standard workflows with simpler interface, use datamol (wrapper around RDKit). Use rdkit for advanced control, custom sanitization, specialized algorithms.
Reflow Machine Maintenance Guidance
49UCSB-NLP-Chang/Skill-Usage
This skill should be considered when you need to answer reflow machine maintenance questions or provide detailed guidance based on thermocouple data, MES data or defect data and reflow technical handbooks. This skill covers how to obtain important concepts, calculations, definitions, thresholds, and others from the handbook and how to do cross validations between handbook and datasets.
Casadi Ipopt Nlp
49UCSB-NLP-Chang/Skill-Usage
Nonlinear optimization with CasADi and IPOPT solver. Use when building and solving NLP problems: defining symbolic variables, adding nonlinear constraints, setting solver options, handling multiple initializations, and extracting solutions. Covers power systems optimization patterns including per-unit scaling and complex number formulations.
Syz Extract Constants
49UCSB-NLP-Chang/Skill-Usage
Defining and extracting kernel constants for syzkaller syzlang descriptions
Browse the most popular Claude skills, all finance & crypto skills, or write your own with the skills generator.