8000 BENCH Benchmark 32bit implementation · scikit-learn/scikit-learn@2c842bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c842bd

Browse files
committed
BENCH Benchmark 32bit implementation
1 parent 31b8b28 commit 2c842bd

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

asv_benchmarks/asv_scalability.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 128 64 32 16 8 4 2 1;
9+
do
10+
last_core=$(($i-1))
11+
taskset -c 0-$last_core \
12+
asv continuous -b PairwiseDistancesArgKmin \
13+
-e main feat/pdr-32bit | tee pairwise_distances_argkmin_asv_${i}_cores.txt
14+
cp -R results results_${i}_cores
15+
done
16+
17+
18+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import numpy as np
2+
3+
from .common import Benchmark
4+
5+
from sklearn.metrics import (
6+
pairwise_distances_argmin,
7+
pairwise_distances_argmin_min
8+
)
9+
10+
from sklearn.cluster import (
11+
AffinityPropagation,
12+
Birch,
13+
MeanShift,
14+
SpectralClustering,
15+
)
16+
17+
from sklearn.neighbors import NearestNeighbors
18+
19+
from sklearn.manifold import (
20+
Isomap,
21+
LocallyLinearEmbedding,
22+
TSNE,
23+
)
24+
25+
from sklearn.semi_supervised import (
26+
LabelPropagation,
27+
LabelSpreading,
28+
)
29+
30+
class PairwiseDistancesArgKminBenchmark(Benchmark):
31+
32+
param_names = ["n_train", "n_test", "n_features"]
33+
params = [
34+
[1000, 10_000, int(1e7)],
35+
[1000, 10_000, 100_000],
36+
[100],
37+
]
38+
39+
def setup(self, n_train, n_test, n_features):
40+
rng = np.random.RandomState(0)
41+
self.X_train = rng.rand(n_train, n_features).astype(np.float32)
42+
self.X_test = rng.rand(n_test, n_features).astype(np.float32)
43+
self.y_train = rng.randint(low=-1, high=1, size=(n_train,))
44+
45+
def time_nearest_neighbors(self, n_train, n_test, n_features):
46+
est = NearestNeighbors(n_neighbors=10).fit(X=self.X_train)
47+
est.kneighbors(self.X_test)

0 commit comments

Comments
 (0)
0