lmcinnes / lmcinnes/umap

UMAP results not robust to StratifiedCV

Open
#488 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.3k
Forks
871
Avg merge
1d 13h
Merged PRs (30d)
5

Description

This is something I've been able to reproduce over 3 different datasets, although all 3 are text embeddings. Each case is a binary classification problem where the positive class frequency is roughly 1% and the dataset size is ~ 3-5k. There are ~ 500 features. I've tried multiple parameter combinations for n_neighbors, target_weight, and min_dist. All plots below use the following parameters: (n_neighbors=50, metric='cosine', random_state=42, target_weight=0.9)

If I take all my labeled data and run UMAP in supervised mode I get a nice separation between my positive and negative classes like so:
![image](https://user-images.githubusercontent.com/8461845/91910161-57f7da80-ec63-11ea-982a-4beddcca6e2a.png)

However, if I hold out 10% of the data using sklearn's StratifiedShuffleSplit and set those labels to -1, the resulting plots look very different, even if I set n_neighbors to 100:
![image](https://user-images.githubusercontent.com/8461845/91910785-8629ea00-ec64-11ea-9f2a-1683fd0525d2.png)

This makes me much less confident about using UMAP as a metric learning tool. Any thoughts as to why this is happening (or more likely what I'm doing wrong) would be greatly appreciated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the supervised UMAP runs with the stated n_neighbors, metric, random_state, target_weight, and StratifiedShuffleSplit setup, then inspect how labels set to -1 are handled. Done means determining whether the changed embedding is expected or a bug, with the behavior and reproduction covered by an appropriate test or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
data-visualization, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.