AttributeError: 'numpy.ndarray' object has no attribute 'transform'
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
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 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