DOC: use notebook-style in plot_prediction_latency.py
@@ -38,6 +38,11 @@ def _not_in_sphinx():
return "__file__" in globals()
+# %%
+# Benchmark and plot helper functions
+# -----------------------------------
+
+
def atomic_benchmark_estimator(estimator, X_test, verbose=False):
"""Measure runtime prediction of each instance."""
n_instances = X_test.shape[0]
@@ -289,13 +294,10 @@ def plot_benchmark_throughput(throughputs, configuration):
plt.show()
-# #############################################################################
-# Main code
-
-start_time = time.time()
-
-# #############################################################################
+# %%
# Benchmark bulk/atomic prediction speed for various regressors
+# -------------------------------------------------------------
+
configuration = {
"n_train": int(1e3),
"n_test": int(1e2),
@@ -325,7 +327,10 @@ configuration = {
}
benchmark(configuration)
-# benchmark n_features influence on prediction speed
+# %%
+# Benchmark n_features influence on prediction speed
+# --------------------------------------------------
+
percentile = 90
percentiles = n_feature_influence(
{"ridge": Ridge()},
@@ -336,9 +341,9 @@ percentiles = n_feature_influence(
)
plot_n_features_influence(percentiles, percentile)
-# benchmark throughput
+# %%
+# Benchmark throughput
+# --------------------
+
throughputs = benchmark_throughputs(configuration)
plot_benchmark_throughput(throughputs, configuration)
-
-stop_time = time.time()
-print("example run in %.2fs" % (stop_time - start_time))
