# scikit-learn-contrib/metric-learn

Metric learning algorithms in Python

Repository: https://github.com/scikit-learn-contrib/metric-learn
Canonical: https://ross.abutalabs.com/products/metric-learn
Homepage: http://contrib.scikit-learn.org/metric-learn/
Language: Python
License: MIT
License Family: permissive
Topics: python, metric-learning, scikit-learn, machine-learning
Last push: 2026-03-19T21:11:11+00:00

## Health v2 (maintenance only)
Score: 56/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 73, release rhythm 8, longevity 100
- inputs: {"age_days": 4687, "days_push": 167, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1438, forks 231 (observed 2026-08-28T04:04:43.973764+00:00)

## What it is
metric-learn is a Python library providing efficient implementations of popular supervised, weakly-supervised, and unsupervised metric learning algorithms such as LMNN, ITML, NCA, and LFDA. As part of scikit-learn-contrib, its API is fully compatible with scikit-learn, enabling use in pipelines and model selection routines.

## Use cases
- learn a Mahalanobis distance metric to improve k-NN classification accuracy
- embed data with Neighborhood Components Analysis before clustering
- train a supervised metric from labeled pairs or triplets
- improve nearest-neighbor retrieval with a learned distance
- plug a metric learner into a scikit-learn pipeline with cross-validation
- compare metric learning algorithms like LMNN, ITML, and SDML on a dataset

## When to choose
- you need learned distance metrics that integrate with scikit-learn pipelines and model selection
- you want a well-documented collection of classic metric learning algorithms under an MIT license
- you are doing research or prototyping in similarity or representation learning with Python

## When to avoid
- you need deep metric learning with neural networks or GPU acceleration
- your project requires actively developed features on the latest scikit-learn versions
- you only need standard distances like Euclidean or cosine without learning

## Facets
- artifact type: library
- maturity: maintenance
- function: machine-learning
- domain: machine-learning, data-science
- platform: python
- tags: metric-learning, scikit-learn, distance-metrics, mahalanobis, similarity-learning

## Member repositories
- scikit-learn-contrib/metric-learn (main) score 56

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:43.973764+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:36:41.714878+00:00, confidence not recorded.
  - readme: https://github.com/scikit-learn-contrib/metric-learn (fetched 2026-08-28T04:04:43.973764+00:00, sha f3569e8e8874)
  - homepage: http://contrib.scikit-learn.org/metric-learn/ (fetched 2026-08-29T11:47:28.546802+00:00, sha 844201115d44)
  - registry_pypi: https://pypi.org/pypi/metric-learn/json (fetched 2026-08-29T11:47:28.557659+00:00, sha f529c4a9a2da)
  - site_page: http://contrib.scikit-learn.org/metric-learn/getting_started.html (fetched 2026-08-29T11:47:28.555756+00:00, sha f4250f1c5c9c)
- Data as of 2026-08-30T08:39:29.467469+00:00.
