8000 DOC: use notebook-style in plot_prediction_latency.py (#22418) · scikit-learn/scikit-learn@f083a12 · GitHub
[go: up one dir, main page]

Skip to content

Commit f083a12

Browse files
ss-is-master-chiefSumit Saha
and
Sumit Saha
authored
DOC: use notebook-style in plot_prediction_latency.py (#22418)
Co-authored-by: Sumit Saha <sumitsaha@SumitSahaMacBook.local>
1 parent 123744a commit f083a12

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

examples/applications/plot_prediction_latency.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def _not_in_sphinx():
3838
return "__file__" in globals()
3939

4040

41+
# %%
42+
# Benchmark and plot helper functions
43+
# -----------------------------------
44+
45+
4146
def atomic_benchmark_estimator(estimator, X_test, verbose=False):
4247
"""Measure runtime prediction of each instance."""
4348
n_instances = X_test.shape[0]
@@ -289,13 +294,10 @@ def plot_benchmark_throughput(throughputs, configuration):
289294
plt.show()
290295

291296

292-
# #############################################################################
293-
# Main code
294-
295-
start_time = time.time()
296-
297-
# #############################################################################
297+
# %%
298298
# Benchmark bulk/atomic prediction speed for various regressors
299+
# -------------------------------------------------------------
300+
299301
configuration = {
300302
"n_train": int(1e3),
301303
"n_test": int(1e2),
@@ -325,7 +327,10 @@ def plot_benchmark_throughput(throughputs, configuration):
325327
}
326328
benchmark(configuration)
327329

328-
# benchmark n_features influence on prediction speed
330+
# %%
331+
# Benchmark n_features influence on prediction speed
332+
# --------------------------------------------------
333+
329334
percentile = 90
330335
percentiles = n_feature_influence(
331336
{"ridge": Ridge()},
@@ -336,9 +341,9 @@ def plot_benchmark_throughput(throughputs, configuration):
336341
)
337342
plot_n_features_influence(percentiles, percentile)
338343

339-
# benchmark throughput
344+
# %%
345+
# Benchmark throughput
346+
# --------------------
347+
340348
throughputs = benchmark_throughputs(configuration)
341349
plot_benchmark_throughput(throughputs, configuration)
342-
343-
stop_time = time.time()
344-
print("example run in %.2fs" % (stop_time - start_time))

0 commit comments

Comments
 (0)
0