lmcinnes / lmcinnes/umap

AttributeError: 'numpy.ndarray' object has no attribute 'transform'

Open
#894 0 comments 1 reaction 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

Hello,

When trying to do a `.fit_transform` on the "Train" data and then a `.transform` on the "Test" data, I get the error:

AttributeError: 'numpy.ndarray' object has no attribute 'transform'

This is my use case:

```
reducer = umap.UMAP(
n_components=11, n_neighbors=20, metric = "manhattan", random_state=42, transform_seed=42, verbose=False
).fit_transform(X_train, y_train)

reducer_test = reducer.transform(X_test)
```

Not sure if this is a bug that the `.fit_transform` and `.transform` can't be used for the "Train" and "Test" data respectively.

Can you tell me how to overcome this error? Thanks!

Side note: Not sure if this is related, but I can overcome the error by removing the `_transform` for the "Train" , however, when I use a random forest, I get just an 82% accuracy (even after doing a grid search for the hyper-parameters). Is it a fair assumption that as I do not `transform` the "Test" data, that the accuracy may be lower than expected?

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

Start at the `umap.UMAP` usage shown in the issue and compare the object returned by `.fit_transform` with the fitted reducer needed for `.transform(X_test)`. Reproduce the train/test example with Python and numpy; done means the issue clarifies the correct fitting and transformation flow and addresses the accuracy question.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.