rapidsai / cuml

cuML - RAPIDS Machine Learning Library
https://docs.rapids.ai/api/cuml/stable/
Apache License 2.0
4.24k stars 532 forks source link

cuml.neighbor.KernelDensity.sample() has a typo that always return NotImplementedError [BUG] #4638

Closed stella-ds closed 2 years ago

stella-ds commented 2 years ago

Describe the bug

cuml==22.04.00a+94.g48120ced9
cupy==9.6.0

cuml.neighbor.KernelDensity.sample() function line 380 has a typo or self.metric != "euclidian"): should be or self.metric != "euclidean"):

the set_params function is not implemented yet to overwrite the metric to bypass this, so .sample always returns NotImplementedError

Steps/Code to reproduce bug

from cuml.neighbors import KernelDensity
from cuml.decomposition import PCA
from sklearn.datasets import fetch_openml
mnist = fetch_openml(name='mnist_784', as_frame=False)
mnist.data = mnist.data[:1000]
pca = PCA(n_components=24, whiten=False)
kde =  KernelDensity(kernel = 'gaussian')
data = pca.fit_transform(mnist.data)
params = {"bandwidth": np.logspace(-1, 3, 50)}
grid = GridSearchCV(kde, params)
grid.fit(data)
kde = grid.best_estimator_
new_data = kde.sample(44, random_state=0)

Expected behavior

image

Environment overview (please complete the following information)

Environment details

<details><summary>Click here to see environment details</summary><pre>

     **git***
     Not inside a git repository

     ***OS Information***
     DISTRIB_ID=Ubuntu
     DISTRIB_RELEASE=20.04
     DISTRIB_CODENAME=focal
     DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"
     NAME="Ubuntu"
     VERSION="20.04.4 LTS (Focal Fossa)"
     ID=ubuntu
     ID_LIKE=debian
     PRETTY_NAME="Ubuntu 20.04.4 LTS"
     VERSION_ID="20.04"
     HOME_URL="https://www.ubuntu.com/"
     SUPPORT_URL="https://help.ubuntu.com/"
     BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
     PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
     VERSION_CODENAME=focal
     UBUNTU_CODENAME=focal
     Linux hyperhub-gpu-d727b6-k4fzh 5.4.144+ rapidsai/cudf#1 SMP Wed Nov 3 09:56:10 PDT 2021 x86_64 x86_64 x86_64 GNU/Linux

     ***GPU Information***
     Fri Mar 18 16:36:27 2022
     +-----------------------------------------------------------------------------+
     | NVIDIA-SMI 450.119.04   Driver Version: 450.119.04   CUDA Version: 11.0     |
     |-------------------------------+----------------------+----------------------+
     | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
     |                               |                      |               MIG M. |
     |===============================+======================+======================|
     |   0  Tesla P4            Off  | 00000000:00:04.0 Off |                    0 |
     | N/A   59C    P0    N/A /  N/A |    719MiB /  7611MiB |      0%      Default |
     |                               |                      |                  N/A |
     +-------------------------------+----------------------+----------------------+

     +-----------------------------------------------------------------------------+
     | Processes:                                                                  |
     |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
     |        ID   ID                                                   Usage      |
     |=============================================================================|
     +-----------------------------------------------------------------------------+

     ***CPU***
     Architecture:                    x86_64
     CPU op-mode(s):                  32-bit, 64-bit
     Byte Order:                      Little Endian
     Address sizes:                   46 bits physical, 48 bits virtual
     CPU(s):                          8
     On-line CPU(s) list:             0-7
     Thread(s) per core:              2
     Core(s) per socket:              4
     Socket(s):                       1
     NUMA node(s):                    1
     Vendor ID:                       GenuineIntel
     CPU family:                      6
     Model:                           63
     Model name:                      Intel(R) Xeon(R) CPU @ 2.30GHz
     Stepping:                        0
     CPU MHz:                         2299.998
     BogoMIPS:                        4599.99
     Hypervisor vendor:               KVM
     Virtualization type:             full
     L1d cache:                       128 KiB
     L1i cache:                       128 KiB
     L2 cache:                        1 MiB
     L3 cache:                        45 MiB
     NUMA node0 CPU(s):               0-7
     Vulnerability Itlb multihit:     Not affected
     Vulnerability L1tf:              Mitigation; PTE Inversion
     Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT Host state unknown
     Vulnerability Meltdown:          Mitigation; PTI
     Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
     Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
     Vulnerability Spectre v2:        Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
     Vulnerability Srbds:             Not affected
     Vulnerability Tsx async abort:   Not affected
     Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear arch_capabilities

     ***CMake***

     ***g++***
     /usr/bin/g++
     g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
     Copyright (C) 2019 Free Software Foundation, Inc.
     This is free software; see the source for copying conditions.  There is NO
     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

     ***nvcc***

     ***Python***
     /root/miniconda3/bin/python
     Python 3.9.7

     ***Environment Variables***
     PATH                            : /root/google-cloud-sdk/bin:/root/miniconda3/bin:/root/miniconda3/condabin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
     LD_LIBRARY_PATH                 : /usr/local/nvidia/lib:/usr/local/nvidia/lib64
     NUMBAPRO_NVVM                   :
     NUMBAPRO_LIBDEVICE              :
     CONDA_PREFIX                    : /root/miniconda3
     PYTHON_PATH                     :

     ***conda packages***
     /root/miniconda3/bin/conda
     # packages in environment at /root/miniconda3:
     #
     # Name                    Version                   Build  Channel
     _libgcc_mutex             0.1                        main
     _openmp_mutex             4.5                       1_gnu
     brotlipy                  0.7.0           py39h27cfd23_1003
     ca-certificates           2021.10.26           h06a4308_2
     certifi                   2021.10.8        py39h06a4308_2
     cffi                      1.15.0           py39hd667e15_1
     charset-normalizer        2.0.4              pyhd3eb1b0_0
     conda                     4.11.0           py39h06a4308_0
     conda-content-trust       0.1.1              pyhd3eb1b0_0
     conda-package-handling    1.7.3            py39h27cfd23_1
     cryptography              36.0.0           py39h9ce1e76_0
     idna                      3.3                pyhd3eb1b0_0
     ld_impl_linux-64          2.35.1               h7274673_9
     libffi                    3.3                  he6710b0_2
     libgcc-ng                 9.3.0               h5101ec6_17
     libgomp                   9.3.0               h5101ec6_17
     libstdcxx-ng              9.3.0               hd4cf53a_17
     ncurses                   6.3                  h7f8727e_2
     openssl                   1.1.1m               h7f8727e_0
     pip                       21.2.4           py39h06a4308_0
     pycosat                   0.6.3            py39h27cfd23_0
     pycparser                 2.21               pyhd3eb1b0_0
     pyopenssl                 21.0.0             pyhd3eb1b0_1
     pysocks                   1.7.1            py39h06a4308_0
     python                    3.9.7                h12debd9_1
     readline                  8.1.2                h7f8727e_1
     requests                  2.27.1             pyhd3eb1b0_0
     ruamel_yaml               0.15.100         py39h27cfd23_0
     setuptools                58.0.4           py39h06a4308_0
     six                       1.16.0             pyhd3eb1b0_0
     sqlite                    3.37.0               hc218d9a_0
     tk                        8.6.11               h1ccaba5_0
     tqdm                      4.62.3             pyhd3eb1b0_1
     tzdata                    2021e                hda174b7_0
     urllib3                   1.26.7             pyhd3eb1b0_0
     wheel                     0.37.1             pyhd3eb1b0_0
     xz                        5.2.5                h7b6447c_0
     yaml                      0.2.5                h7b6447c_0
     zlib                      1.2.11               h7f8727e_4

</pre></details>

Additional context Add any other context about the problem here.

vyasr commented 2 years ago

Hi @stella-ds I think you meant to open this issue in the cuml repository? I'm going to transfer it for you, but feel free to post again if there's a reason this should be noted in cudf. Thanks!

stella-ds commented 2 years ago

right! sorry about that, thanks @vyasr !

divyegala commented 2 years ago

@RAMitchell could I ask you to take a look at this?

RAMitchell commented 2 years ago

Thanks, I'll take a look.