transform function changes the embedding_
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 871
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Description
Hi,
I have noticed a weird thing, I am not sure if its the expected behavior of UMAP so I am posting this.
I have realized that when I use the .transform method using a new dataset that has the same dimensions as the initial data that I used to fit UMAP, the embedding_ values change. But the embedding_ values won't change if I transform new data with different dimensions.
import umap
import numpy as np
data = np.random.rand(100,50)
fitter = umap.UMAP().fit(data)
print(fitter.embedding_[:5,])
print()
transform_different = np.random.rand(200,50)
transform_same =np.random.rand(100,50)
fitter.transform(transform_different)
print(fitter.embedding_[:5,])
print()
fitter.transform(transform_same)
print(fitter.embedding_[:5,])
The output is
[[ 3.01767 -6.116551 ]
[ 5.664277 -4.0695806]
[ 4.170628 -5.1638904]
[ 6.079433 -6.3256063]
[ 5.794976 -4.5939784]]
[[ 3.01767 -6.116551 ]
[ 5.664277 -4.0695806]
[ 4.170628 -5.1638904]
[ 6.079433 -6.3256063]
[ 5.794976 -4.5939784]]
[[ 2.6579268e+00 -7.8308420e+00]
[ 1.5021657e+00 -6.3121238e+00]
[ 3.2839913e+00 -8.0168781e+00]
[-3.5597345e-01 -6.4087682e+00]
[ 6.9772257e-03 -8.1144466e+00]]
As you see the first two outputs contain the same embedding values. but when I transform using a dataset (100, 50), the same dimensions as the initial one, the embedding values change.
Isn't the embedding supposed to be maintained always? if the embedding changes the ability to transform new data will be deteriorated right?
Hope you understand.
Thanks in advance for your time!
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 Python reproduction in the issue and inspect the UMAP .transform method and embedding_ behavior when the new dataset has the same versus different dimensions. Determine whether changing embedding_ is expected, then add a regression test or documentation that captures the intended behavior and verifies that transformation remains reliable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100