Skip to content

Commit fac6872

Browse files
ASV add benchmark for beam search (#194)
1 parent 2baa25e commit fac6872

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

asv_benchmarks/benchmarks/fastcan.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FastCanBenchmark(Benchmark):
1616
"""
1717

1818
param_names = ["task", "alg"]
19-
params = (["classif", "reg"], ["h", "eta"])
19+
params = (["classif", "reg"], ["h", "eta", "beam"])
2020

2121
def setup_cache(self):
2222
"""Pickle a fitted estimator for all combinations of parameters"""
@@ -30,11 +30,17 @@ def setup_cache(self):
3030

3131
if alg == "h":
3232
eta = False
33-
else:
33+
beam_width = 1
34+
elif alg == "eta":
3435
eta = True
36+
beam_width = 1
37+
else:
38+
eta = False
39+
beam_width = 10
3540
estimator = FastCan(
3641
n_features_to_select=20,
3742
eta=eta,
43+
beam_width=beam_width
3844
)
3945
estimator.fit(X, y)
4046

pixi.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ time-eta = "python -m timeit -n 5 -s 'import numpy as np; from fastcan import Fa
8888
profile-minibatch = { cmd = '''python -c "import cProfile; import numpy as np; from fastcan import minibatch; X = np.random.rand(100, 3000); y = np.random.rand(100, 20); cProfile.run('minibatch(X, y, 1000, 10, verbose=0)', sort='{{ SORT }}')"''', args = [{ arg = "SORT", default = "cumtime" }] }
8989
time-narx = '''python -m timeit -n 1 -s "import numpy as np; from fastcan.narx import make_narx; rng = np.random.default_rng(5); X = rng.random((1000, 10)); y = rng.random((1000, 2)); m = make_narx(X, y, 10, max_delay=2, poly_degree=2, verbose=0)" "m.fit(X, y, coef_init='one_step_ahead', verbose=1)"'''
9090
profile-narx = { cmd = '''python -c "import cProfile; import numpy as np; from fastcan.narx import make_narx; rng = np.random.default_rng(8); X = rng.random((3000, 3)); y = rng.random((3000, 3)); m = make_narx(X, y, 10, max_delay=10, poly_degree=2, verbose=0); cProfile.run('m.fit(X, y, coef_init=[0]*33)', sort='{{ SORT }}')"''', args = [{ arg = "SORT", default = "tottime" }] }
91+
time-beam = "python -m timeit -n 5 -s 'import numpy as np; from fastcan import FastCan; X = np.random.rand(3000, 100); y = np.random.rand(3000, 20)' 's = FastCan(20, beam_width=3, verbose=0).fit(X, y)'"
9192

9293
[feature.asv.tasks]
9394
asv-build = { cmd = "python -m asv machine --machine {{ MACHINE }} --yes && python -m asv run --show-stderr -v --machine {{ MACHINE }} {{ EXTRA_ARGS }}", cwd = "asv_benchmarks", args = [{ arg = "MACHINE", default = "MacOS-M1" }, { arg = "EXTRA_ARGS", default = "" }] }

0 commit comments

Comments
 (0)