Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $ pytest --ignore=cuml/tests/dask --ignore=cuml/tests/test_nccl.py

If you want a list of the available Python tests:
```bash
$ pytest cuML/tests --collect-only
$ pytest cuml/tests --collect-only
```

### Manual Process
Expand Down
24 changes: 24 additions & 0 deletions notebooks/tools/cuml_benchmarks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,30 @@
"execute_benchmark(\"PCA\", runner)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### KernelPCA<a id=\"kernel_pca\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"runner = cuml.benchmark.runners.SpeedupComparisonRunner(\n",
" bench_rows=[400, 800, 1600, 3200, 6400, 12800],\n",
" bench_dims=WIDE_FEATURES,\n",
" dataset_name=DATA_CLASSIFICATION,\n",
" input_type=INPUT_TYPE,\n",
" n_reps=N_REPS\n",
")\n",
"\n",
"execute_benchmark(\"KernelPCA\", runner)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
2 changes: 2 additions & 0 deletions python/cuml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ if(CUML_CPU)

set(CUML_ALGORITHMS "linearregression")
list(APPEND CUML_ALGORITHMS "pca")
list(APPEND CUML_ALGORITHMS "kpca")
list(APPEND CUML_ALGORITHMS "tsvd")
list(APPEND CUML_ALGORITHMS "elasticnet")
list(APPEND CUML_ALGORITHMS "logisticregression")
Expand Down Expand Up @@ -179,6 +180,7 @@ add_subdirectory(cuml/svm)
add_subdirectory(cuml/tsa)

add_subdirectory(cuml/experimental/linear_model)
add_subdirectory(cuml/experimental/decomposition)

if(DEFINED cython_lib_dir)
rapids_cython_add_rpath_entries(TARGET cuml PATHS "${cython_lib_dir}")
Expand Down
7 changes: 7 additions & 0 deletions python/cuml/cuml/benchmark/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ def all_algorithms():
name="PCA",
accepts_labels=False,
),
AlgorithmPair(
sklearn.decomposition.KernelPCA,
cuml.experimental.KernelPCA,
shared_args=dict(),
name="KernelPCA",
accepts_labels=False,
),
AlgorithmPair(
sklearn.decomposition.TruncatedSVD,
cuml.decomposition.tsvd.TruncatedSVD,
Expand Down
23 changes: 22 additions & 1 deletion python/cuml/cuml/decomposition/utils.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2022, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,19 @@ from libcpp cimport bool

ctypedef int underlying_type_t_solver

cdef extern from "raft/distance/distance_types.hpp" namespace "raft::distance::kernels" nogil:
enum KernelType:
LINEAR,
POLYNOMIAL,
RBF,
TANH

cdef struct KernelParams:
KernelType kernel
int degree
double gamma
double coef0

cdef extern from "cuml/decomposition/params.hpp" namespace "ML" nogil:

ctypedef enum solver "ML::solver":
Expand All @@ -41,3 +54,11 @@ cdef extern from "cuml/decomposition/params.hpp" namespace "ML" nogil:
cdef cppclass paramsPCA(paramsTSVD):
bool copy
bool whiten

cdef cppclass paramsKPCA(paramsTSVD):
KernelParams kernel
size_t n_training_samples
bool copy
bool remove_zero_eig
bool fit_inverse_transform

1 change: 1 addition & 0 deletions python/cuml/cuml/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from cuml.experimental.fil import ForestInference
from cuml.experimental.decomposition import KernelPCA
26 changes: 26 additions & 0 deletions python/cuml/cuml/experimental/decomposition/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# =============================================================================
# Copyright (c) 2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================



set(cython_sources "")
add_module_gpu_default("kpca.pyx" ${kpca_algo} ${decomposition_algo})

rapids_cython_create_modules(
CXX
SOURCE_FILES "${cython_sources}"
LINKED_LIBRARIES "${cuml_sg_libraries}"
MODULE_PREFIX experimental_
ASSOCIATED_TARGETS cuml
)
17 changes: 17 additions & 0 deletions python/cuml/cuml/experimental/decomposition/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from cuml.experimental.decomposition.kpca import KernelPCA
Loading