YingfanWang/PaCMAP

Doesn't work in sklearn's Pipeline

jochenater opened this issue · 8 comments

pipe = Pipeline([('reduce_dim', pacman()), ('kmeans, KMeans())])

AttributeError: 'PaCMAP' object has no attribute 'random_state'

Would be great if it did

Could you report the version of your PaCMAP? In some cases, update to the newest version via pip install --upgrade pacmap could solve the problem.

I just installed it today so should be the newest version. It's:
0.5.2

I see. I have reproduced your error locally. Let me try to fix this.

The problem with the current version of PaCMAP is that the random_state parameter got renamed into seed into the PaCMAP instance. When you try to print the PaCMAP instances, however, the sklearn convention will ask the instance to print all its parameter as is. I will try to bring up a hotfix later today. To use the PaCMAP before the hotfix released, please try to avoid printing it out (e.g. pacman = pacmap.PaCMAP())

A hotfix have been pushed to the PyPI. However, given that current PaCMAP algorithm is transductive instead of inductive, it does not implement transform() method (just as the sklearn TSNE implementation), which means you will still be unable to use it in Pipeline. Please try to use the workaround provide in my last comment.

Thanks for the quick fix!
I've just seen the other issue about the lack of transform method. I think it would greatly improve the usability if it had one ;)

For people that just need to use it in their pipeline, here is some ugly hack:

pacman = PaCMAP() def transform(self, *args, **kwargs): return self.fit_transform(*args, **kwargs) pacman.transform = transform.__get__(pacman)

The transform method has been added in the latest release.