Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 051a6b8

Browse filesBrowse files
committed
BENCH Add ASV benchmark setup for radius_neighborhood
1 parent c4d8c4a commit 051a6b8
Copy full SHA for 051a6b8

File tree

2 files changed

+41
-0
lines changed
Filter options

2 files changed

+41
-0
lines changed

‎asv_benchmarks/asv_scalability.sh

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Launch a ASV benchmark on groups of CPU
4+
# for scalability inspection
5+
#
6+
# Results are saved in given folders and files.
7+
#
8+
for i in 20 16 8 4 2 1;
9+
do
10+
last_core=$(($i-1))
11+
taskset -c 0-$last_core \
12+
asv continuous -b PairwiseDistancesRadiusNeighborhood \
13+
-e main pairwise-distances-radius-neighborhood | tee pairwise_distances_radius_neighborhood_asv_${i}_cores.txt
14+
cp -R results results_${i}_cores
15+
done

‎asv_benchmarks/benchmarks/pdr.py

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import numpy as np
2+
3+
from .common import Benchmark
4+
5+
from sklearn.neighbors import NearestNeighbors
6+
7+
8+
class PairwiseDistancesRadiusNeighborhoodBenchmark(Benchmark):
9+
10+
param_names = ["n_train", "n_test", "n_features"]
11+
params = [
12+
[1000, 10_000],
13+
[1000, 10_000, 100_000],
14+
[100],
15+
]
16+
17+
def setup(self, n_train, n_test, n_features):
18+
rng = np.random.RandomState(0)
19+
X_train = rng.rand(n_train, n_features)
20+
self.X_test = rng.rand(n_test, n_features)
21+
self.est = NearestNeighbors().fit(X_train)
22+
23+
def time_pairwise_distances_argmin(self, n_train, n_test, n_features):
24+
self.est.radius_neighbors(
25+
X=self.X_test, return_distance=True, sort_results=True
26+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.