dask-ml icon indicating copy to clipboard operation
dask-ml copied to clipboard

Can support score_samples of sklearn.neighbors.KernelDensity in dask_ml.wrappers.ParallelPostFit?

Open WanBenLe opened this issue 3 years ago • 1 comments

When I run these code will rasie the error, can support score_samples of sklearn.neighbors.KernelDensity in dask_ml.wrappers.ParallelPostFit or I can do what I need by referring to other code in dask_ml.wrappers and by adding some new code (and ensuring the correct xign of the result)?

from dask.distributed import Client
import joblib
from sklearn.neighbors import KernelDensity
from dask_ml.wrappers import ParallelPostFit
from numpy.random import randint

data = randint(0, 100, (10000, 1))
clf = ParallelPostFit(estimator=KernelDensity())
client = Client(processes=False)
with joblib.parallel_backend('dask'):
    clf.fit(data)
d2 = clf.score_samples(data)

I get the 'ParallelPostFit' object has no attribute 'score_samples' error.

Traceback (most recent call last):
  File "D:\JetBrains\PyCharm 2021.2.3\plugins\python\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\JetBrains\PyCharm 2021.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/~/~/MVABTest.py", line 12, in <module>
    d2 = clf.score_samples(data)
AttributeError: 'ParallelPostFit' object has no attribute 'score_samples'

WanBenLe avatar Feb 16 '22 06:02 WanBenLe

I'm going to move this issue to the dask-ml issue tracker, but please update it to include a Minimal Reproducible Example.

jsignell avatar Feb 16 '22 14:02 jsignell