Does self.distance_metric.rdist use a v-table look up? (I am curious. This may not be actionable)
Yes, it does.
Does self.distance_metric.rdist use a v-table look up? (I am curious. This may not be actionable)
Yes, it does.
| import sys | |
| import cudf | |
| import joblib | |
| import numpy as np | |
| impo |
| %%cython --annotate | |
| #cython: boundscheck=False | |
| #cython: wraparound=False | |
| #cython: cdivision=True | |
| ## Adapted from sklearn.neighbors.Mahalanobis | |
| # https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/neighbors/_dist_metrics.pyx#L669 | |
| import numpy as np | |
| cimport numpy as np |
| # Cython compile instructions | |
| import numpy | |
| from setuptools import setup, Extension | |
| from Cython.Build import build_ext | |
| # To compile, use | |
| # python setup.py build --inplace | |
| extensions = [ | |
| Extension("stdvect_to_ndarray", |
| import numpy as np | |
| from sklearn.neighbors import DistanceMetric | |
| from .common import Benchmark | |
| class DistanceMetricBenchmark(Benchmark): | |
| param_names = ["n", "d"] | |
| params = ([100, 1000, 10_000], [5, 10, 100]) | |
| def setup(self, n, d): |
| from sklearn.feature_selection import mutual_info_regression, mutual_info_classif | |
| from sklearn.neighbors import KernelDensity, NearestNeighbors | |
| from .common import Benchmark | |
| from sklearn.datasets import make_classification, make_regression | |
| class RemovedCheckBenchmarks(Benchmark): | |
| param_names = ['n', 'd'] | |
| params = ( |
| import numpy as np | |
| from scipy.linalg import cho_solve, cholesky | |
| from sklearn.gaussian_process.kernels import RBF | |
| from sklearn.datasets import make_regression | |
| from sklearn.model_selection import train_test_split | |
| kernel = RBF(length_scale=1.0) | |
| X, y = make_regression() | |
| X_train, X_test, y_train, y_test = train_test_split(X, y) |
| import numpy as np | |
| from sklearn.neighbors import KDTree, BallTree | |
| from .common import Benchmark | |
| class BinaryTreeStatsBenchmark(Benchmark): | |
| """ | |
| Base class for BinaryTree benchmarks for removing statistics. | |
| """ |