<jupyter_start><jupyter_text>All tests are done single-threaded, collecting the CPU time.<jupyter_code>bps_times = []
N_ITERATIONS = 1000
for i in range (0, N_ITERATIONS):
    if i % 20 == 0:
        print("iteration n. " + str(i))
    start = time.process_time()
    xtr_bps = aptbps.adaptive_encode(xtr_sample, n_parts=1, verbose=False, n_jobs=1)
    end = time.process_time()
    total_training_time = (end - start)
    bps_times.append(total_training_time)
mean_bps_time = np.mean(bps_times)
print("mean bps time: " + str(mean_bps_time))
fftkde_aptbps_times = []
N_ITERATIONS = 1000
for i in range (0, N_ITERATIONS):
    if i % 20 == 0:
        print("iteration n. " + str(i))
    start = time.process_time()
    # triangle-fftkde
    xtr_fftkde_aptbps = aptbps.adaptive_encode(xtr_sample, kde='fft', n_parts=2, verbose=False, n_jobs=1)
    end = time.process_time()
    total_training_time = (end - start)
    fftkde_aptbps_times.append(total_training_time)
mean_fftkde_aptbps_time = np.mean(fftkde_aptbps_times)
print("mean fftkde aptbps time: " + str(mean_fftkde_aptbps_time))
gkde_aptbps_times = []
N_ITERATIONS = 1000
for i in range (0, N_ITERATIONS):
    if i % 20 == 0:
        print("iteration n. " + str(i))
    start = time.process_time()
    # triangle-gkde
    xtr_gkde_aptbps = aptbps.adaptive_encode(xtr_sample, n_parts=2, verbose=False, n_jobs=1)
    end = time.process_time()
    total_training_time = (end - start)
    gkde_aptbps_times.append(total_training_time)
mean_gkde_aptbps_time = np.mean(gkde_aptbps_times)
print("mean gaussian kde aptbps time: " + str(mean_gkde_aptbps_time))
# Calculate standard deviations
gkde_std = np.std(gkde_aptbps_times)
fftkde_std = np.std(fftkde_aptbps_times)
bps_std = np.std(bps_times)
print(gkde_std, fftkde_std, bps_std)
# Save data
np.savetxt("bps_encoding_times.csv", bps_times, delimiter=',', header='')
np.savetxt("gkde_aptbps_encoding_times.csv", gkde_aptbps_times, delimiter=',', header='')
np.savetxt("fftkde_aptbps_encoding_times.csv", fftkde_aptbps_times, delimiter=',', header='')
fig, ax = plt.subplots()
ax.bar(["Gaussian KDE\nAPTBPS", "FFT KDE\nAPTBPS", "BPS"], 
       [mean_gkde_aptbps_time,mean_fftkde_aptbps_time,mean_bps_time], 
       yerr=[5*gkde_std, 5*fftkde_std, 5*bps_std], 
       error_kw={'label': '$5\sigma$', 'capsize': 5})

ax.set_title("Mean encoding process time over 1000 iterations", weight='bold')
ax.set_yscale("log")
ax.set_axisbelow(True)
ax.yaxis.grid(True, color='#EEEEEE')
ax.legend()
fig.tight_layout()
ax.set_ylabel("time (s) | log scale")
ax.set_xlabel("Encoding method")
fig.savefig('encoding-time-comparison.svg')
# Values:
print("bps mean: " + str(mean_bps_time))
print("bps std: " + str(bps_std))

print("gkde aptbps mean: " + str(mean_gkde_aptbps_time))
print("gkde aptbps std: " + str(gkde_std))

print("bps mean: " + str(mean_fftkde_aptbps_time))
print("bps std: " + str(fftkde_std))<jupyter_output>bps mean: 0.18784678974599925
bps std: 0.0019620951073589525
gkde aptbps mean: 17.71632170351896
gkde aptbps std: 0.09248776022151502
bps mean: 0.6485394895859975
bps std: 0.017205025944769876
StarcoderdataJupyterStructuredCleanDedup