Shift of UMAP points when using .transform()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 871
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Description
Hi,
I am encountering a point shift issue when fitting umap to embeddings X_train and then applying the fit to embeddings X_test not seen during training.
Here is an example data set creation to demonstrate the issue:
The new points are all shifted to the bottom left corner of the UMAP space:

This is the code for the example above
```import numpy as np
import pandas as pd
import plotly.express as px
from umap import UMAP
n_examples = 1000
X = np.random.random((n_examples,128))
X_train = X[:n_examples//2]
X_test = X[n_examples//2:]
mapper = UMAP()
mapper.fit(X_train)
low_dim_emb_train = mapper.transform(X_train)
low_dim_emb_test = mapper.transform(X_test)
df_train = pd.DataFrame({"x":low_dim_emb_train[:,0],"y":low_dim_emb_train[:,1],"dataset":["train"]*len(low_dim_emb_train)})
df_test = pd.DataFrame({"x":low_dim_emb_test[:,0],"y":low_dim_emb_test[:,1],"dataset":["test"]*len(low_dim_emb_test)})
df_plot = pd.concat([df_train,df_test])
px.scatter(df_plot,x="x",y="y",color="dataset")
```
What could be the issue?
Many thanks
Olivia
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python reproducer with UMAP.fit() on X_train and transform() on both X_train and X_test, then inspect the transform behavior and related UMAP implementation entry points. Done means explaining or correcting the reported bottom-left shift for unseen points and adding a regression check for the demonstrated case; no specific file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, plotly, python
- Domain
- data-visualization, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100