Adding precomputed distances for Parametric UMAP
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 871
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Description
I'm trying to figure out how we could enable precomputed distances for Parametric UMAP, since fit_transform only takes in `X` as either the distance matrix, _or_ the data, but Parametric UMAP would need both the distance matrix _and_ the data as input.
One option that wouldn't require modification to anything but parametric_umap.py would be to add a fit_transform method that takes in precomputed distances, and grabs the data as self._X:
```python
def fit_transform(self, X, y=None, precomputed_distances=None):
if self.metric == "precomputed":
if precomputed_distances is None:
raise ValueError(
"Precomputed distances must be supplied if metric \
is precomputed."
)
# prepare X for traning the network
self._X = X
# geneate the graph on precomputed distances
return super().fit_transform(precomputed_distances, y)
else:
return super().fit_transform(X, y)
```
then, in _fit_embed_data, grab back X.
```python
def _fit_embed_data(self, X, n_epochs, init, random_state):
if self.metric == "precomputed":
X = self._X
...
```
Does that seem reasonable? I can make a PR if so.
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 in parametric_umap.py at fit_transform and _fit_embed_data, where the issue proposes passing both training data and precomputed distances. Trace how Parametric UMAP currently prepares X and delegates to the parent implementation, then determine how both inputs should be retained without changing non-precomputed behavior. Done means Parametric UMAP accepts precomputed distances while still training on the original data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100