Fitting dask_ml.decomposition.PCA returns TypeError: sum() got an unexpected keyword argument 'keepdims'
- Dominant language
- Python
- Stars
- 951
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
My data is actually a `scipy.sparse.csr_matrix`. In order to convert this to a `dask.array`, I am sending the data with `client.scatter` and then I am using `dask.array.from_delayed`. Lastly, I am using `fit`, which is returning this error: `TypeError: sum() got an unexpected keyword argument 'keepdims'`. Below you can find the information about the variables used in the code, the code itself and the full-traceback. **I will try to add a minimal-working example.**
### Variable Information:
X before conversion to dask array:
```
>>>X.type
>>>X.shape
(10000, 1000)
```
X_distributed:
```
>>>X_distributed
```
X after conversion to dask array:
```
>>>X
dask.array
>>>X.type
>>>X.shape
(10000, 1000)
>>>type(X.compute())
```
### Code
```
>>>from dask_ml.decomposition import PCA as DaskPca
# Do some stuff here.
#
#
>>>dask_pca = DaskPca(n_components=None)
>>>X_distributed = self.client.scatter(X)
>>>X = da.from_delayed(X_distributed, shape=X.shape, dtype=float)
>>>dask_pca.fit(X=X)
```
### Full-traceback
```
File "/home/dodzilla/my_project/components_with_adapter/dimension_reduction/reduction_adapter.py", line 101, in fit_transform
dask_pca.fit(X=X)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask_ml/decomposition/pca.py", line 190, in fit
self._fit(X)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask_ml/decomposition/pca.py", line 325, in _fit
singular_values,
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/base.py", line 436, in compute
results = schedule(dsk, keys, **kwargs)
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/client.py", line 2573, in get
results = self.gather(packed, asynchronous=asynchronous, direct=direct)
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/client.py", line 1873, in gather
asynchronous=asynchronous,
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/client.py", line 768, in sync
self.loop, func, *args, callback_timeout=callback_timeout, **kwargs
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/utils.py", line 334, in sync
raise exc.with_traceback(tb)
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/utils.py", line 318, in f
result[0] = yield future
File "/home/dodzilla/.local/lib/python3.6/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/dodzilla/.local/lib/python3.6/site-packages/distributed/client.py", line 1729, in _gather
raise exception.with_traceback(traceback)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/optimization.py", line 982, in __call__
return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/core.py", line 149, in get
result = _execute_task(task, cache)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/core.py", line 119, in _execute_task
return func(*args2)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/utils.py", line 29, in apply
return func(*args, **kwargs)
File "/home/dodzilla/.local/lib/python3.6/site-packages/dask/array/reductions.py", line 539, in mean_chunk
total = sum(x, dtype=dtype, **kwargs)
File "<__array_function__ internals>", line 6, in sum
File "/home/dodzilla/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2182, in sum
initial=initial, where=where)
File "/home/dodzilla/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
TypeError: sum() got an unexpected keyword argument 'keepdims'
```
Contributor guide
Assessment
This issue has not been assessed yet.