UMAP PicklingError: ("Can't pickle <class 'numpy.dtype[float32]'>: ...)

584 Views Asked by At

Trying to run UMAP causes an error:

import pandas as pd
import numpy as np
import umap

df = pd.DataFrame(np.arange(25).reshape(-1,5))

um = umap.UMAP(random_state=0)
um.fit(df)

PicklingError: ("Can't pickle <class 'numpy.dtype[float32]'>: it's not found as numpy.dtype[float32]", 'PicklingError while hashing array([[ 0., 1., 2., 3., 4.],\n [ 5., 6., 7., 8., 9.],\n [10., 11., 12., 13., 14.],\n [15., 16., 17., 18., 19.],\n
[20., 21., 22., 23., 24.]], dtype=float32): PicklingError("Can't pickle <class 'numpy.dtype[float32]'>: it's not found as numpy.dtype[float32]")')

​ How do I resolve this?

1

There are 1 best solutions below

0
On

The problem seems to be with Numpy. I was running 1.20 when hitting this error. Downgrading with

pip install numpy==1.19

resolves it.