### Linux venv-based environment setup Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6-development-guide Used in GitHub Actions. Creates a Python virtual environment, installs dependencies, activates components, and installs the package with setup.py. ```bash python -m venv venv source venv/bin/activate pip install -r dependencies-dev source .github/scripts/activate_components.sh python setup.py install --single-version-externally-managed --record=record.txt ``` -------------------------------- ### Development install (editable) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Performs an editable install using setup.py develop with GPU and distributed support disabled. ```bash # Development install (editable) NO_DIST=1 NO_DPC=1 python setup.py develop ``` -------------------------------- ### Install scikit-learn-intelex from PyPI Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Installs the scikit-learn-intelex package from PyPI. Requires Python ≥ 3.10 and scikit-learn ≥ 1.0. ```bash pip install scikit-learn-intelex ``` -------------------------------- ### Build documentation locally with build-doc.sh Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.3-documentation-build Run from the repository root after installing pandoc, Python dependencies, and building the library. Output is placed in doc/_build/html/. ```bash cd doc ./build-doc.sh ``` -------------------------------- ### Install via Conda (Intel channel) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Creates a conda environment named 'sklex' and installs scikit-learn-intelex from Intel's channel, recommended for Intel® Distribution for Python users. ```bash conda create -n sklex -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels scikit-learn-intelex conda activate sklex ``` -------------------------------- ### Install via Conda (conda-forge channel) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Creates a conda environment named 'sklex' and installs scikit-learn-intelex from the conda-forge channel, recommended for general use. ```bash conda create -n sklex -c conda-forge --override-channels scikit-learn-intelex conda activate sklex ``` -------------------------------- ### Windows conda-based environment setup Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6-development-guide Matches the Azure Pipelines WindowsCondaEnv job. Creates a conda environment named CB with Python, impi-devel, and pyyaml, installs dal-devel>=2025.6.1, and builds via conda-recipe\bld.bat. ```bash conda create -n CB -c conda-forge python= impi-devel pyyaml call activate CB pip install -r dependencies-dev conda install -c conda-forge "dal-devel>=2025.6.1" call conda-recipe\bld.bat ``` -------------------------------- ### Linux conda-based environment setup Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6-development-guide Matches the Azure Pipelines LinuxCondaEnv job. Creates a conda environment named CB with Python, mpich, and pyyaml, installs dal-devel>=2025.6.1, and builds via conda-recipe/build.sh. ```bash conda create -n CB -c conda-forge python= mpich pyyaml conda activate CB conda install -c conda-forge "dal-devel>=2025.6.1" # or set DALROOT pip install -r dependencies-dev source /opt/intel/oneapi/compiler/latest/env/vars.sh # if DPC++ installed ./conda-recipe/build.sh ``` -------------------------------- ### Minimal CPU-only build (no GPU, no distributed) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Sets DALROOT to the oneDAL installation path and disables GPU and distributed support via NO_DIST=1 and NO_DPC=1 before running setup.py build. ```bash # Minimal CPU-only build (no GPU, no distributed) export DALROOT=/path/to/onedal NO_DIST=1 NO_DPC=1 python setup.py build ``` -------------------------------- ### Install test dependencies and run sklearnex test groups Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.2-testing-infrastructure Install test dependencies and run all sklearnex test groups, producing JSON reports. Individual groups can be run with pytest commands. ```bash pip install -r requirements-test.txt ``` ```bash bash conda-recipe/run_test.sh --json-report ``` ```bash pytest --pyargs sklearnex ``` ```bash pytest --pyargs onedal ``` ```bash pytest -s tests/ ``` -------------------------------- ### Example verbose output for DBSCAN.fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Example output from verbose logging showing the accelerated version running on CPU and the fallback to original Scikit-learn for sklearn.cluster.DBSCAN.fit. This output appears when SKLEARNEX_VERBOSE is set to INFO. ```text INFO:sklearnex: sklearn.cluster.DBSCAN.fit: running accelerated version on CPU INFO:sklearnex: sklearn.cluster.DBSCAN.fit: fallback to original Scikit-learn ``` -------------------------------- ### Run sklearn conformance tests with options Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.2-testing-infrastructure Run sklearn conformance tests, optionally with GPU offloading or preview mode deselections. ```bash bash .ci/scripts/run_sklearn_tests.sh ``` ```bash bash .ci/scripts/run_sklearn_tests.sh gpu ``` ```bash SKLEARNEX_PREVIEW=YES bash .ci/scripts/run_sklearn_tests.sh ``` -------------------------------- ### Full build with GPU and distributed support (Linux) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Requires both DALROOT and I_MPI_ROOT environment variables to be set for a complete build with GPU and distributed support on Linux. ```bash # Full build with GPU and distributed support (Linux) export DALROOT=/path/to/onedal export I_MPI_ROOT=/path/to/mpi python setup.py build ``` -------------------------------- ### Offload computation to GPU with target_offload Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex Use config_context with target_offload to move computations to a SYCL-compatible GPU. The option accepts a device name string like "gpu:0" or a dpctl.SyclQueue object. ```python from sklearnex import config_context with config_context(target_offload="gpu:0"): clustering = DBSCAN(eps=3, min_samples=2).fit(X) ``` -------------------------------- ### GPU execution with config_context and target_offload (with patching) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Use config_context with target_offload to run DBSCAN on a GPU device. Requires patching scikit-learn with patch_sklearn() first. Data is automatically moved to the specified device. A model fitted on GPU must also perform prediction/scoring on GPU. ```python import numpy as np from sklearnex import patch_sklearn, config_context patch_sklearn() from sklearn.cluster import DBSCAN X = np.array([[1., 2.], [2., 2.], [2., 3.], [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) with config_context(target_offload="gpu:0"): clustering = DBSCAN(eps=3, min_samples=2).fit(X) ``` -------------------------------- ### Parallel build with 8 threads Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Runs a parallel build using 8 threads via the --parallel flag, with distributed support disabled. ```bash # Parallel build with 8 threads NO_DIST=1 python setup.py build --parallel 8 ``` -------------------------------- ### sklearnex.basic_statistics.BasicStatistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Basic statistics computation with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearnex.basic_statistics.BasicStatistics ### Description Basic statistics computation with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - All parameters ### Data Format - Dense or CSR sparse ### Notes - No `sample_weight` with CSR ``` -------------------------------- ### Conda build script wrapper command Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.2-conda-packaging Both build.sh and bld.bat call this command to delegate compilation to setup.py, which drives CMake, Cython, and pybind11 builds. ```bash python setup.py install --single-version-externally-managed --record record.txt ``` -------------------------------- ### Array API Support Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms A subset of algorithms supports array API-conforming inputs (e.g., dpnp.ndarray, torch.tensor on XPU). Array API must be enabled via config_context(array_api_dispatch=True). ```APIDOC ## Array API Support ### Description A subset of algorithms supports array API-conforming inputs (e.g., dpnp.ndarray, torch.tensor on XPU). Array API must be enabled via config_context(array_api_dispatch=True). ### Patched Classes with Array API Support - `sklearnex.basic_statistics.BasicStatistics` - `sklearnex.basic_statistics.IncrementalBasicStatistics` - `sklearn.cluster.DBSCAN` - `sklearn.covariance.EmpiricalCovariance` - `sklearnex.covariance.IncrementalEmpiricalCovariance` - `sklearn.decomposition.PCA` - `sklearn.ensemble.ExtraTreesClassifier` - `sklearn.ensemble.ExtraTreesRegressor` - `sklearn.ensemble.RandomForestClassifier` - `sklearn.ensemble.RandomForestRegressor` - `sklearn.linear_model.LinearRegression` - `sklearn.linear_model.Ridge` - `sklearnex.linear_model.IncrementalLinearRegression` - `sklearnex.linear_model.IncrementalRidge` - `sklearn.svm.NuSVC` - `sklearn.svm.NuSVR` - `sklearn.svm.SVC` - `sklearn.svm.SVR` ``` -------------------------------- ### GPU execution with config_context and target_offload (without patching) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Use config_context with target_offload to run DBSCAN on a GPU device without patching scikit-learn. Import the accelerated estimator directly from sklearnex.cluster. Data is automatically moved to the specified device. A model fitted on GPU must also perform prediction/scoring on GPU. ```python import numpy as np from sklearnex import config_context from sklearnex.cluster import DBSCAN X = np.array([[1., 2.], [2., 2.], [2., 3.], [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) with config_context(target_offload="gpu:0"): clustering = DBSCAN(eps=3, min_samples=2).fit(X) ``` -------------------------------- ### Enable verbose logging with SKLEARNEX_VERBOSE=INFO Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Set the SKLEARNEX_VERBOSE environment variable to INFO to enable verbose logging that shows whether the accelerated or fallback implementation is running. This is useful for verifying which implementation executes during a dispatched call. ```bash export SKLEARNEX_VERBOSE=INFO ``` -------------------------------- ### Command-line patching with python -m sklearnex Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Run an existing script without modifying it. Patching is applied automatically before the script runs. ```bash python -m sklearnex my_application.py ``` -------------------------------- ### Package identity and versioning in meta.yaml Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.2-conda-packaging Defines the package name and version sourced from the GIT_DESCRIBE_TAG environment variable during repository builds. In feedstock builds, the version is static and the source block points to a GitHub archive. ```yaml package: name: scikit-learn-intelex version: {{ environ.get('GIT_DESCRIBE_TAG') }} ``` -------------------------------- ### versions.json format Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.3-documentation-build Seed file for the version switcher, containing only the "latest" entry initially. The full file is regenerated by the release script and deployed to GitHub Pages. ```json [ { "name": "latest", "version": "2025.1", "url": "/scikit-learn-intelex/latest/" }, { "name": "2025.1", "version": "2025.1", "url": "/scikit-learn-intelex/2025.1/" }, { "name": "2024.7", "version": "2024.7", "url": "/scikit-learn-intelex/2024.7/" } ] ``` -------------------------------- ### IncrementalBasicStatistics constructor Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.5-basic-statistics Constructor for the incremental estimator. Supports incremental computation via partial_fit calls. batch_size is only used by fit() and defaults to 5 * n_features. ```python IncrementalBasicStatistics(result_options="all", batch_size=None) ``` -------------------------------- ### CMake Invocation Commands for Backend Build Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Shows the three subprocess calls run by custom_build_cmake_clib for each interface (host, dpc, spmd_dpc). The -S flag points to the scripts directory, -B to the build directory for the interface, and -j{n_threads} controls parallelism. ```bash cmake -S scripts/ -B build/backend_{iface}/ [options...] cmake --build build/backend_{iface}/ -j{n_threads} cmake --install build/backend_{iface}/ ``` -------------------------------- ### enable_thread_pinning Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4-daal4py-interface Binds threads to physical cores. Disabled by default. ```APIDOC ## enable_thread_pinning ### Description Binds threads to physical cores. Disabled by default. ### Parameters - **enabled** (bool) - Optional - Whether to enable thread pinning. Default is True. ``` -------------------------------- ### Enable verbose logging Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Enable verbose logging to confirm which implementation (sklearnex or stock sklearn) is executing a given call. Prints messages indicating whether each operation uses the Intel oneDAL backend or falls back to stock scikit-learn. ```python import logging logging.basicConfig(level=logging.INFO) ``` -------------------------------- ### LogisticRegression._onedal_fit CPU and GPU paths Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3-algorithm-implementations Shows the branch inside _onedal_fit: CPU path delegates to daal4py_fit via _onedal_cpu_fit, GPU path uses the onedal estimator with a queue. The queue parameter is None for CPU and a dpctl.SyclQueue for GPU. ```python CPU path: self._onedal_cpu_fit(X, y, sample_weight) # delegates to daal4py_fit GPU path: self._onedal_estimator.fit(X, y, queue=queue) ``` -------------------------------- ### BasicStatistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.5-basic-statistics Compute basic statistics in a single fit call. Accepts a result_options parameter to control which statistics are computed. ```APIDOC ## BasicStatistics ### Description Compute basic statistics in a single fit call. Accepts a result_options parameter to control which statistics are computed. ### Constructor Parameters - **result_options** (str or list of str) - Optional - Controls which statistics are computed. Can be "all", a single statistic name, or a list of statistic names. Default is "all". ### Available Statistics | result_options value | Output attribute | Description | | --- | --- | --- | | "min" | `min_` | Per-feature minimum | | "max" | `max_` | Per-feature maximum | | "sum" | `sum_` | Per-feature sum | | "mean" | `mean_` | Per-feature mean | | "variance" | `variance_` | Per-feature variance (Bessel's correction) | | "variation" | `variation_` | Per-feature variation (Bessel's correction) | | "sum_squares" | `sum_squares_` | Per-feature sum of squares | | "standard_deviation" | `standard_deviation_` | Per-feature unbiased standard deviation | | "sum_squares_centered" | `sum_squares_centered_` | Per-feature centered sum of squares | | "second_order_raw_moment" | `second_order_raw_moment_` | Per-feature second raw moment | | "all" | all of the above | Computes every statistic | ### Output Attributes Each output attribute is an `ndarray` of shape `(n_features,)`. An attribute is only present on the fitted estimator if its corresponding option was requested. ### Module `sklearnex/basic_statistics/basic_statistics.py` ### SPMD Variant An SPMD (distributed) variant exists at `sklearnex/spmd/basic_statistics/basic_statistics.py`. ``` -------------------------------- ### PatchingConditionsChain usage in LinearRegression.fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/2.1-patching-and-dispatching Shows how to use PatchingConditionsChain to decide at runtime whether to use the oneDAL backend or fall back to sklearn. Conditions are (bool, str) tuples; and_conditions requires all true. get_status(logs=True) logs INFO 'running accelerated version on CPU' when enabled, or DEBUG per failing condition and INFO 'fallback to original Scikit-learn' when disabled. ```python _patching_status = PatchingConditionsChain("sklearnex.linear_model.LinearRegression.fit") _patching_status.and_conditions([ (dtype in [np.float32, np.float64], "X not float32 or float64"), (not sparse, "sparse input not supported"), ]) if _patching_status.get_status(logs=True): # call oneDAL backend else: # call sklearn backend ``` -------------------------------- ### sklearn.decomposition.PCA Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Principal Component Analysis with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.decomposition.PCA ### Description Principal Component Analysis with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `svd_solver` in `['full','covariance_eigh','onedal_svd']` ### Data Format - No sparse ``` -------------------------------- ### Debug build Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/5.1-building-from-source Builds with debug symbols by setting DEBUG_BUILD=1 and using the --debug flag, with distributed support disabled. ```bash # Debug build NO_DIST=1 DEBUG_BUILD=1 python setup.py build --debug ``` -------------------------------- ### Building PatchingConditionsChain for LogisticRegression.fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3-algorithm-implementations Accumulates boolean conditions and reason strings for a named operation, then logs 'running accelerated version on CPU/GPU' when all conditions are True, or 'fallback to original Scikit-learn' with the first failing reason when any is False. Observable via SKLEARNEX_VERBOSE=INFO and matched by tests in sklearnex/tests/test_patching.py137-143. ```python # Building conditions patching_status = PatchingConditionsChain( "sklearn.linear_model.LogisticRegression.fit" ) patching_status.and_conditions([ (self.penalty == "l2", "Only l2 penalty is supported."), (self.dual == False, "dual=True is not supported."), (sample_weight is None, "Sample weight is not supported."), (target_type == "binary", "Only binary classification is supported"), ]) ``` -------------------------------- ### daalfini Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4-daal4py-interface Finalizes the MPI environment (MPI_Finalize). Required when using distributed mode without mpi4py. ```APIDOC ## daalfini ### Description Finalises the MPI environment (MPI_Finalize). Required when using distributed mode without mpi4py. ``` -------------------------------- ### sklearn.cluster.KMeans Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms K-Means clustering with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.cluster.KMeans ### Description K-Means clustering with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `algorithm='lloyd'`; `n_clusters!=1`; uniform weights; `init='k-means++'` falls back to CPU ### Data Format - None ``` -------------------------------- ### table.__dlpack__ Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/2.3-data-conversion Exports the table as a DLPack capsule, allowing other frameworks (PyTorch, JAX, array_api_strict) to consume the table directly. Supports specifying stream, max version, device, and copy options. ```APIDOC ## table.__dlpack__ ### Description Exports the table as a DLPack capsule, allowing other frameworks (PyTorch, JAX, array_api_strict) to consume the table directly. Supports specifying stream, max version, device, and copy options. ### Method __dlpack__ ### Parameters - **stream** - Optional - Stream for asynchronous operations - **max_version** - Optional - Maximum DLPack version supported - **dl_device** - Optional - Target device for the export (e.g., (kDLCPU, 0) to move to host) - **copy** - Optional - Whether to copy the data ### Response Returns a DLPack capsule representing the table data. ``` -------------------------------- ### BasicStatistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Estimator unique to sklearnex for computing basic statistics. Supports result_options parameter and array API. ```APIDOC ## BasicStatistics ### Description Estimator unique to sklearnex for computing basic statistics. Supports result_options parameter and array API. ### Class `sklearnex.basic_statistics.BasicStatistics` ### Parameters - `result_options` - Supported parameter ### Supported Platforms - CPU: Yes - GPU: Yes - SPMD: Yes ``` -------------------------------- ### In-script patching with patch_sklearn Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Call patch_sklearn() before importing sklearn modules to route supported estimators to accelerated versions. Unsupported algorithms fall back silently to stock scikit-learn. ```python from sklearnex import patch_sklearn patch_sklearn()   from sklearn.cluster import DBSCAN # now routes to sklearnex import numpy as np   X = np.array([[1., 2.], [2., 2.], [2., 3.], [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) clustering = DBSCAN(eps=3, min_samples=2).fit(X) ``` -------------------------------- ### table.__dlpack_device__ Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/2.3-data-conversion Returns the device type and ID where the table's underlying memory resides. Returns either kDLCPU or kDLOneAPI depending on the memory location. ```APIDOC ## table.__dlpack_device__ ### Description Returns the device type and ID where the table's underlying memory resides. Returns either kDLCPU or kDLOneAPI depending on the memory location. ### Method __dlpack_device__ ### Response Returns a tuple (device_type, device_id) where device_type is either kDLCPU or kDLOneAPI. ``` -------------------------------- ### IncrementalBasicStatistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.5-basic-statistics Compute statistics incrementally via partial_fit batches. Accepts the same result_options parameter as BasicStatistics. ```APIDOC ## IncrementalBasicStatistics ### Description Compute statistics incrementally via partial_fit batches. Accepts the same result_options parameter as BasicStatistics. ### Constructor Parameters - **result_options** (str or list of str) - Optional - Controls which statistics are computed. Can be "all", a single statistic name, or a list of statistic names. Default is "all". ### Available Statistics | result_options value | Output attribute | Description | | --- | --- | --- | | "min" | `min_` | Per-feature minimum | | "max" | `max_` | Per-feature maximum | | "sum" | `sum_` | Per-feature sum | | "mean" | `mean_` | Per-feature mean | | "variance" | `variance_` | Per-feature variance (Bessel's correction) | | "variation" | `variation_` | Per-feature variation (Bessel's correction) | | "sum_squares" | `sum_squares_` | Per-feature sum of squares | | "standard_deviation" | `standard_deviation_` | Per-feature unbiased standard deviation | | "sum_squares_centered" | `sum_squares_centered_` | Per-feature centered sum of squares | | "second_order_raw_moment" | `second_order_raw_moment_` | Per-feature second raw moment | | "all" | all of the above | Computes every statistic | ### Output Attributes Each output attribute is an `ndarray` of shape `(n_features,)`. An attribute is only present on the fitted estimator if its corresponding option was requested. ### Module `sklearnex/basic_statistics/incremental_basic_statistics.py` ``` -------------------------------- ### Instantiate oneDAL SVM estimator in _onedal_fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.4-svm Sets the _onedal_estimator attribute by instantiating the _onedal_factory with SVM hyperparameters, then calls fit with sample_weight, class_count, and queue. Used during _onedal_fit in sklearnex/svm/_base.py. ```python self._onedal_estimator = self._onedal_factory(**onedal_params) self._onedal_estimator.fit(X, y, sample_weight, class_count=..., queue=queue) ``` -------------------------------- ### sklearn.decomposition.IncrementalPCA Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Incremental Principal Component Analysis with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.decomposition.IncrementalPCA ### Description Incremental Principal Component Analysis with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `svd_solver` in `['full','covariance_eigh']` ### Data Format - No sparse ### Notes - Preview mode only ``` -------------------------------- ### sklearn.cluster.DBSCAN Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms DBSCAN clustering with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.cluster.DBSCAN ### Description DBSCAN clustering with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `metric='euclidean'` only; `algorithm` in `['brute','auto']` ### Data Format - Dense only ``` -------------------------------- ### sklearn.neighbors.NearestNeighbors Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Nearest Neighbors search with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.neighbors.NearestNeighbors ### Description Nearest Neighbors search with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `algorithm='brute'` only; no callable `weights`; `metric` in `[euclidean, manhattan, minkowski, chebyshev, cosine]` ### Data Format - Dense only ``` -------------------------------- ### sklearn.svm.SVC Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Support Vector Classification with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.svm.SVC ### Description Support Vector Classification with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `kernel` in `["linear","rbf"]` - no `class_weight` - `probability=False` recommended ### Data Format - Dense only; no negative weights ### Notes - Binary only; `probability=True` runs initial fit on GPU, calibration on CPU ``` -------------------------------- ### num_threads Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4-daal4py-interface Returns the current configured thread count. ```APIDOC ## num_threads ### Description Returns the current configured thread count. ### Returns - **int** - Current thread count. ``` -------------------------------- ### sklearn.linear_model.LinearRegression Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Linear Regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.linear_model.LinearRegression ### Description Linear Regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - No `sample_weight`, no `positive=True` ### Data Format - Dense only ``` -------------------------------- ### Direct import from sklearnex submodules Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Import accelerated estimators directly from sklearnex submodules without patching. This keeps accelerated and stock scikit-learn classes independent, giving explicit control over which estimators are accelerated. ```python from sklearnex.cluster import DBSCAN as exDBSCAN from sklearn.cluster import DBSCAN as stockDBSCAN ``` -------------------------------- ### C++ generated code structure for PCA algorithm Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4.1-code-generation-system Shows the C++ side of the generated code for a given algorithm namespace (e.g., algorithms::pca). Includes typemap, interface struct, and manager struct templates. ```cpp // --- typemap (Result) --- typedef daal::algorithms::pca::ResultPtr algorithms_pca_result; extern "C" NumericTablePtr* get_algorithms_pca_result_eigenvalues(algorithms_pca_result* obj_); // ... (implementation in .cpp) // --- interface struct --- struct pca__iface__ : public algo_manager__iface__ { virtual algorithms_pca_result* compute(data_or_file& data, ..., bool setup_only) = 0; }; // --- manager struct (template) --- template struct pca_manager : public pca__iface__ { // member storage for all parameters // _algob: SharedPtr to Batch // batch(), distributed(), compute() methods }; ``` -------------------------------- ### Verifying patch status with is_patched_instance Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Check whether a given object uses the accelerated implementation. Returns False before patching and True after patching and re-importing the estimator. ```python from sklearnex import patch_sklearn, is_patched_instance from sklearn.linear_model import LinearRegression   is_patched_instance(LinearRegression()) # False before patching   patch_sklearn() from sklearn.linear_model import LinearRegression # re-import after patch is_patched_instance(LinearRegression()) # True ``` -------------------------------- ### sklearn.neighbors.KNeighborsRegressor Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms K-Nearest Neighbors Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.neighbors.KNeighborsRegressor ### Description K-Nearest Neighbors Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `algorithm='brute'` only; no callable `weights`; `metric` euclidean/minkowski(p=2) ### Data Format - Dense only ``` -------------------------------- ### Cython generated code structure for PCA algorithm Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4.1-code-generation-system Shows the Cython side (.pyx) of the generated code, including cdef classes for result and manager, and the compute method. ```cython cdef class algorithms_pca_result: cdef algorithms_pca_result* c_ptr @property def eigenvalues(self): ... # calls get_algorithms_pca_result_eigenvalues cdef extern from "daal4py.h": cdef cppclass c_pca_manager__iface__: algorithms_pca_result* compute(data_or_file data, ..., bool setup_only) except + cdef class pca_manager__iface__: cdef c_pca_manager__iface__sptr c_ptr cdef class pca_manager(pca_manager__iface__): def __cinit__(self, fptype="double", method="defaultDense", ...): self.c_ptr = mk_pca(...) def compute(self, data, ...): ... ``` -------------------------------- ### Run SPMD distributed mode with MPI Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex Launch a multi-GPU SPMD execution using mpirun with mpi4py. This mode is supported on Linux for selected estimators in sklearnex.spmd. ```bash mpirun -n 4 python linear_regression_spmd.py ``` -------------------------------- ### sklearn.ensemble.ExtraTreesRegressor Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Extra Trees Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.ensemble.ExtraTreesRegressor ### Description Extra Trees Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - Same as `RandomForestRegressor` (GPU) ### Data Format - No multi-output; no sparse ``` -------------------------------- ### Assemble onedal_params dict in BaseSVC._onedal_fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.4-svm Builds the parameter dictionary passed to the oneDAL SVM estimator from the scikit-learn estimator's hyperparameters. Includes C, nu, kernel, degree, gamma, coef0, tol, shrinking, max_iter, and cache_size. ```python onedal_params = { "C": self.C, "nu": self.nu, "kernel": self.kernel, "degree": self.degree, "gamma": self._compute_gamma_sigma(X), "coef0": self.coef0, "tol": self.tol, "shrinking": self.shrinking, "max_iter": self.max_iter, "cache_size": self.cache_size, } ``` -------------------------------- ### Using GPU arrays with array API dispatch Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.1-quick-start Use array API dispatch to avoid redundant data transfers when data is already on a GPU device as a dpnp.ndarray or torch.tensor. Requires enabling array API support in scikit-learn via SCIPY_ARRAY_API environment variable and setting array_api_dispatch=True in config_context. Not all estimators support array API inputs. ```python import os os.environ["SCIPY_ARRAY_API"] = "1" import torch from sklearnex import config_context from sklearnex.cluster import DBSCAN X = torch.tensor(..., device="xpu") # already on Intel GPU with config_context(array_api_dispatch=True): clustering = DBSCAN(eps=3, min_samples=2).fit(X) ``` -------------------------------- ### sklearn.linear_model.LogisticRegression Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Logistic Regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.linear_model.LogisticRegression ### Description Logistic Regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `solver='newton-cg'` only; no `class_weight`, `sample_weight`, `dual`, `intercept_scaling!=1`, `warm_start`, `l1_ratio` ### Data Format - None ### Notes - Binary only ``` -------------------------------- ### table.__sycl_usm_array_interface__ Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/2.3-data-conversion Exposes the SYCL USM array interface property. This is only available when compiled with the DPC backend (ONEDAL_DATA_PARALLEL). ```APIDOC ## table.__sycl_usm_array_interface__ ### Description Exposes the SYCL USM array interface property. This is only available when compiled with the DPC backend (ONEDAL_DATA_PARALLEL). ### Method __sycl_usm_array_interface__ ### Response Returns a dictionary representing the SYCL USM array interface. ``` -------------------------------- ### IncrementalBasicStatistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Estimator unique to sklearnex for incremental basic statistics. Uses partial_fit and finalize_fit workflow. ```APIDOC ## IncrementalBasicStatistics ### Description Estimator unique to sklearnex for incremental basic statistics. Uses partial_fit and finalize_fit workflow. ### Class `sklearnex.basic_statistics.IncrementalBasicStatistics` ### Methods - `partial_fit` - Incremental fitting - `finalize_fit` - Finalize the fitting process ### Supported Platforms - CPU: Yes - GPU: Yes - SPMD: Yes ``` -------------------------------- ### Patch scikit-learn with sklearnex Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex Use patch_sklearn() to replace standard scikit-learn algorithms with accelerated versions. After patching, imports from sklearn return the optimized implementations; unsupported algorithms fall back silently. ```python from sklearnex import patch_sklearn patch_sklearn() from sklearn.cluster import DBSCAN # now backed by sklearnex ``` -------------------------------- ### deselected_tests.yaml entry format Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.2-testing-infrastructure Each entry is a pytest node ID, optionally followed by version condition(s) and a platform string. ```yaml - node/path/test_file.py::test_name # always deselect ``` ```yaml - node/path/test_file.py::test_name >=1.5 # deselect for sklearn >= 1.5 ``` ```yaml - node/path/test_file.py::test_name >=1.5,<1.7 # deselect for sklearn 1.5.x and 1.6.x ``` ```yaml - node/path/test_file.py::test_name >=1.2 win32 # deselect on Windows, sklearn >= 1.2 ``` -------------------------------- ### TreeState struct definition (src/tree_visitor.h) Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4.3-tree-model-export-and-distributed-transceiver Groups the two heap-allocated arrays (node_ar and value_ar) with metadata scalars. The caller takes ownership of node_ar and value_ar. ```cpp struct TreeState { skl_tree_node * node_ar; double * value_ar; size_t max_depth; size_t node_count; size_t leaf_count; size_t class_count; }; ``` -------------------------------- ### sklearn.neighbors.KNeighborsClassifier Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms K-Nearest Neighbors Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.neighbors.KNeighborsClassifier ### Description K-Nearest Neighbors Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `algorithm='brute'` only; no callable `weights`; `metric` in `[euclidean, manhattan, minkowski, chebyshev, cosine]` ### Data Format - Dense only ### Notes - At least 2 classes ``` -------------------------------- ### Coverage Reporting: pytest invocation with --cov flags Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/6.2-testing-infrastructure Used in CI to collect coverage for the sklearnex and onedal test suites. The --cov-report= (empty) defers report generation; a separate Codecov upload step processes the combined .coverage.* files. ```bash --cov=onedal --cov=sklearnex --cov-config= --cov-append --cov-branch --cov-report= ``` -------------------------------- ### __getattr__ lazy finalization Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.5-basic-statistics Triggers finalization on demand when accessing opt_ attributes like mean_. Calls _onedal_finalize_fit() if _need_to_finalize is True. ```python def __getattr__(self, attr): sattr = attr.removesuffix("_") is_statistic_attr = ( sattr in self._onedal_estimator.options if "_onedal_estimator" in self.__dict__ else False ) if is_statistic_attr: if self._need_to_finalize: self._onedal_finalize_fit() return getattr(self._onedal_estimator, attr) return self.__getattribute__(attr) ``` -------------------------------- ### Apply class weights to sample_weight Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.4-svm Multiplies class weights into per-sample weights before passing to the backend, because oneDAL only accepts per-sample weights. Iterates over class_weight_ entries and scales sample_weight for each class. ```python for i, v in enumerate(self.class_weight_): sample_weight[y == i] *= v ``` -------------------------------- ### sklearn.covariance.EmpiricalCovariance Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Empirical covariance estimation with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.covariance.EmpiricalCovariance ### Description Empirical covariance estimation with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - All parameters ### Data Format - Dense only ### Notes - Preview mode only ``` -------------------------------- ### sklearn.linear_model.Ridge Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Ridge regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.linear_model.Ridge ### Description Ridge regression with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - `solver='auto'`; no `sample_weight`; no `positive=True`; `alpha` scalar ### Data Format - Dense only ``` -------------------------------- ### sklearn.ensemble.ExtraTreesClassifier Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Extra Trees Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.ensemble.ExtraTreesClassifier ### Description Extra Trees Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - Same as `RandomForestClassifier` (GPU) ### Data Format - No multi-output; no sparse ### Notes - At least 2 classes ``` -------------------------------- ### table Properties Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/2.3-data-conversion The table object exposes properties for inspecting its data: has_data, shape, row_count, column_count, kind, and dtype. ```APIDOC ## table Properties ### Description The table object exposes properties for inspecting its data: has_data, shape, row_count, column_count, kind, and dtype. ### Properties - **has_data** (bool) - Whether the table holds any data - **shape** (tuple(int, int)) - (row_count, column_count) - **row_count** (int) - Number of rows - **column_count** (int) - Number of columns - **kind** (str) - "homogen", "csr", or "empty" - **dtype** (numpy.dtype) - Element data type ``` -------------------------------- ### sklearn.ensemble.RandomForestRegressor Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Random Forest Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.ensemble.RandomForestRegressor ### Description Random Forest Regressor with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - No `warm_start`, `ccp_alpha!=0`, `criterion!='squared_error'`, `oob_score=True`, `sample_weight!=None`, `n_estimators>6024` ### Data Format - No multi-output; no sparse ``` -------------------------------- ### SPMD BasicStatistics subclass overriding _onedal_basic_statistics Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3.5-basic-statistics Defines a BasicStatistics subclass for SPMD distributed computation. It inherits all logic from the batch sklearnex BasicStatistics and only swaps the backend class to the SPMD-capable onedal_BasicStatistics, enabling multi-process distributed statistics computation. ```python class BasicStatistics(BasicStatistics_Batch): __doc__ = BasicStatistics_Batch.__doc__ _onedal_basic_statistics = staticmethod(onedal_BasicStatistics) ``` -------------------------------- ### IncrementalRidge Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Estimator unique to sklearnex for incremental ridge regression. Uses partial_fit and finalize_fit workflow. ```APIDOC ## IncrementalRidge ### Description Estimator unique to sklearnex for incremental ridge regression. Uses partial_fit and finalize_fit workflow. ### Class `sklearnex.linear_model.IncrementalRidge` ### Methods - `partial_fit` - Incremental fitting - `finalize_fit` - Finalize the fitting process ### Supported Platforms - CPU: Yes - GPU: Yes - SPMD: Yes ``` -------------------------------- ### dispatch() usage in LogisticRegression.fit Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/3-algorithm-implementations Typical usage of dispatch() inside a public method of a sklearnex estimator. Passes a dictionary with 'onedal' and 'sklearn' keys mapping to the respective callable implementations. dispatch() determines the active SYCL queue, checks GPU/CPU support, and routes to the oneDAL or sklearn fallback. ```python # sklearnex/linear_model/logistic_regression.py (line ~153) def fit(self, X, y, sample_weight=None): dispatch( self, "fit", { "onedal": self.__class__._onedal_fit, "sklearn": _sklearn_LogisticRegression.fit, }, X, y, sample_weight, ) ``` -------------------------------- ### my_procid Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4-daal4py-interface Returns this process's MPI rank (MPI_Comm_rank). Returns 0 outside MPI. ```APIDOC ## my_procid ### Description Returns this process's MPI rank (MPI_Comm_rank). Returns 0 outside MPI. ### Returns - **int** - MPI rank of the current process. ``` -------------------------------- ### IncrementalLinearRegression Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Estimator unique to sklearnex for incremental linear regression. Uses partial_fit and finalize_fit workflow. ```APIDOC ## IncrementalLinearRegression ### Description Estimator unique to sklearnex for incremental linear regression. Uses partial_fit and finalize_fit workflow. ### Class `sklearnex.linear_model.IncrementalLinearRegression` ### Methods - `partial_fit` - Incremental fitting - `finalize_fit` - Finalize the fitting process ### Supported Platforms - CPU: Yes - GPU: Yes - SPMD: Yes ``` -------------------------------- ### sklearn.ensemble.RandomForestClassifier Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/1.2-supported-algorithms Random Forest Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ```APIDOC ## sklearn.ensemble.RandomForestClassifier ### Description Random Forest Classifier with GPU offload. Triggered via config_context(target_offload="gpu:0") or on-device array API objects. ### Parameters #### Key Parameter Constraints - No `warm_start`, `ccp_alpha!=0`, `criterion!='gini'`, `oob_score=True`, `sample_weight!=None`, `n_estimators>6024` ### Data Format - No multi-output; no sparse ### Notes - At least 2 classes ``` -------------------------------- ### num_procs Source: https://deepwiki.com/uxlfoundation/scikit-learn-intelex/4-daal4py-interface Returns the MPI communicator size (MPI_Comm_size). Returns 1 outside MPI. ```APIDOC ## num_procs ### Description Returns the MPI communicator size (MPI_Comm_size). Returns 1 outside MPI. ### Returns - **int** - MPI communicator size. ```