Skip to content

Commit d29ce47

Browse files
DOC smooth speed plot (#131)
* DOC smooth speed plot
1 parent a5bd1b2 commit d29ce47

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

.github/workflows/emscripten.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111
- name: Build WASM wheel
12-
uses: pypa/cibuildwheel@v3.1.2
12+
uses: pypa/cibuildwheel@v3.1.3
1313
env:
1414
CIBW_PLATFORM: pyodide
1515
- name: Upload package

.github/workflows/wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
steps:
3434
- uses: actions/checkout@v4
3535
- name: Build wheels
36-
uses: pypa/cibuildwheel@v3.1.2
36+
uses: pypa/cibuildwheel@v3.1.3
3737
env:
3838
CIBW_SKIP: "*_i686 *_ppc64le *_s390x *_universal2 *-musllinux_* cp314*"
3939
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.10"

examples/plot_speed.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,30 +169,38 @@ def baseline(X, y, t):
169169
# following iterated selection process, the eta-cosine method will be much faster than
170170
# the h-correlation method.
171171

172-
X = rng.random((3000, 100))
172+
from timeit import repeat
173+
174+
X = rng.random((3000, 400))
173175
y = rng.random((3000, 20))
174176

175-
n_features_max = 30
177+
feature_num = np.arange(20, 61, step=10, dtype=int)
178+
176179

177-
time_h = np.zeros(n_features_max, dtype=float)
178-
time_eta = np.zeros(n_features_max, dtype=float)
179-
for i in range(n_features_max):
180-
time_h[i] = timeit(
181-
f"s = FastCan({i + 1}, verbose=0).fit(X, y)",
182-
number=10,
180+
time_h = np.zeros(len(feature_num), dtype=float)
181+
time_eta = np.zeros(len(feature_num), dtype=float)
182+
for i, n_feats in enumerate(feature_num):
183+
times_h = repeat(
184+
f"s = FastCan({n_feats + 1}, verbose=0).fit(X, y)",
185+
number=1,
186+
repeat=10,
183187
globals=globals(),
184188
)
185-
time_eta[i] = timeit(
186-
f"s = FastCan({i + 1}, eta=True, verbose=0).fit(X, y)",
187-
number=10,
189+
time_h[i] = np.median(times_h)
190+
times_eta = repeat(
191+
f"s = FastCan({n_feats + 1}, eta=True, verbose=0).fit(X, y)",
192+
number=1,
193+
repeat=10,
188194
globals=globals(),
189195
)
196+
time_eta[i] = np.median(times_eta)
197+
190198

191-
feature_num = np.arange(n_features_max, dtype=int) + 1
192199
plt.plot(feature_num, time_h, label="h-correlation")
193200
plt.plot(feature_num, time_eta, label=r"$\eta$-cosine")
194201
plt.title("Elapsed Time Comparison")
195202
plt.xlabel("Number of Selected Features")
196203
plt.ylabel("Elapsed Time (s)")
204+
plt.xticks(feature_num)
197205
plt.legend(loc="lower right")
198206
plt.show()

0 commit comments

Comments
 (0)