saved before topic change
This commit is contained in:
@@ -28,7 +28,7 @@ from sklearn.metrics import r2_score
|
||||
# k3: cost per relax_attempt (should be equal across heaps)
|
||||
# k4: cost per decrease-key (binary: should scale with log2N; fibonacci: should be constant)
|
||||
|
||||
csv_file = "results/synthetic_data/raw/20260418_095837.csv"
|
||||
csv_file = "results/synthetic_data/raw/20260421_031740.csv"
|
||||
save_folder = f"results/synthetic_data/derived/{os.path.splitext(os.path.basename(csv_file))[0]}/processing_time_analysis"
|
||||
os.makedirs(save_folder, exist_ok=True)
|
||||
|
||||
@@ -85,6 +85,10 @@ log_n = np.log2(np.array(nodes)).reshape(-1, 1)
|
||||
bin_reg = LinearRegression().fit(log_n, k4_bin)
|
||||
r2_bin = r2_score(k4_bin, bin_reg.predict(log_n))
|
||||
|
||||
# fibonacci: k4 ~ log₂N 회귀
|
||||
fib_reg = LinearRegression().fit(log_n, k4_fib)
|
||||
r2_fib = r2_score(k4_fib, fib_reg.predict(log_n))
|
||||
|
||||
n_line = np.linspace(min(nodes), max(nodes), 300)
|
||||
log_n_line = np.log2(n_line).reshape(-1, 1)
|
||||
|
||||
@@ -96,6 +100,8 @@ ax.plot(nodes, k4_bin, marker="o", color="steelblue", label="binary k4")
|
||||
ax.plot(nodes, k4_fib, marker="s", color="darkorange", label="fibonacci k4")
|
||||
ax.plot(n_line, bin_reg.predict(log_n_line), color="steelblue", linestyle="--", linewidth=1.5,
|
||||
label=f"binary fit (∝ log₂N) R²={r2_bin:.3f}")
|
||||
ax.plot(n_line, fib_reg.predict(log_n_line), color="steelblue", linestyle="--", linewidth=1.5,
|
||||
label=f"fibonacci fit (∝ log₂N) R²={r2_fib:.3f}")
|
||||
ax.set_xlabel("N (nodes)")
|
||||
ax.set_ylabel("k4 — decrease-key cost per call [s]")
|
||||
ax.set_title("k4 (decrease-key unit cost) vs N")
|
||||
|
||||
Reference in New Issue
Block a user