Skip to content

Commit abc9bf5

Browse files
committed
Add code to generate plots as shown in the paper
The runtime analysis scripts now contain the code used to generate the plots shown within the paper. modified: paper/benchmark/runtime_analysis_colincrease.py modified: paper/benchmark/runtime_analysis_rowincrease.py modified: paper/benchmark/runtime_analysis_symmetric.py
1 parent 13007ac commit abc9bf5

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

paper/benchmark/runtime_analysis_colincrease.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def mbpls_ade4(data, num_comp=20):
7474
# Calculation Measurements
7575
include_timing = True
7676

77+
# Plot timing graphs in the end
78+
plot_results = True
79+
7780
# Datasets
7881
x_sizes = np.arange(1000, 1001, 1000)
7982
y_sizes = np.arange(100, 20001, 100)
@@ -235,3 +238,37 @@ class bcolors:
235238
pickle.dump(indicator_matrix_shared, open('indicator_matrix_colincrease.pkl', 'wb'))
236239
pickle.dump(timing_results_shared, open('timing_results_colincrease.pkl', 'wb'))
237240

241+
# Generate the plot of the runtimes (Not shown in the paper)
242+
if plot_results:
243+
import matplotlib
244+
matplotlib.rc('text', usetex=True)
245+
matplotlib.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath}"]
246+
import matplotlib.pyplot as plt
247+
timing_mean = timing_results.min(axis=3)
248+
249+
# Only include those results with runtimes lower than 1000 seconds in average
250+
Ade4 = timing_mean[0, timing_mean[0, :, 0] < 1000, 0]
251+
UNIPALS = timing_mean[1, timing_mean[1, :, 0] < 1000, 0]
252+
KERNEL = timing_mean[2, timing_mean[2, :, 0] < 1000, 0]
253+
NIPALS = timing_mean[3, timing_mean[3, :, 0] < 1000, 0]
254+
SIMPLS = timing_mean[4, timing_mean[4, :, 0] < 1000, 0]
255+
256+
plt.figure(figsize=(6, 4))
257+
plt.plot(Ade4, 'b--', label=r'Ade4 ($P>N$)')
258+
plt.plot(UNIPALS, 'c', label='UNIPALS with fixed samples')
259+
plt.plot(KERNEL, 'g', label='KERNEL with fixed samples')
260+
plt.plot(NIPALS, 'r', label='NIPALS with fixed samples')
261+
plt.plot(SIMPLS, 'm', label='SIMPLS with fixed samples\n(Non-Multiblock')
262+
plt.legend(fontsize=13, loc=(0.1, 0.45))
263+
plt.xlabel(r'Number of samples $N$ in $\boldsymbol{X}$', fontsize=14)
264+
plt.ylabel('Time in seconds', fontsize=14)
265+
plt.ylim((0, 15))
266+
plt.xlim(0, 199)
267+
xticks = np.arange(-1, 200, 50)
268+
xticks[0] = -1
269+
xlabels = xticks*100 + 100
270+
xlabels[0] = 100
271+
plt.xticks(xticks, xlabels, fontsize=13)
272+
plt.yticks(fontsize=13)
273+
plt.tight_layout()
274+
plt.show()

paper/benchmark/runtime_analysis_rowincrease.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def mbpls_ade4(data, num_comp=20):
7474
# Calculation Measurements
7575
include_timing = True
7676

77+
# Plot timing graphs in the end
78+
plot_results = True
79+
7780
# Datasets
7881
x_sizes = np.arange(100, 20001, 100)
7982
y_sizes = np.arange(1000, 1001, 1000)
@@ -236,3 +239,39 @@ class bcolors:
236239
print('Saving data')
237240
pickle.dump(indicator_matrix_shared, open('indicator_matrix_rowincrease.pkl', 'wb'))
238241
pickle.dump(timing_results_shared, open('timing_results_rowincrease.pkl', 'wb'))
242+
243+
244+
# Generate plot as shown in Figure 2a in the paper
245+
if plot_results:
246+
import matplotlib
247+
matplotlib.rc('text', usetex=True)
248+
matplotlib.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath}"]
249+
import matplotlib.pyplot as plt
250+
timing_mean = timing_results.min(axis=3)
251+
252+
# Only include those results with runtimes lower than 1000 seconds in average
253+
Ade4 = timing_mean[0, 0, timing_mean[0, 0] < 1000]
254+
UNIPALS = timing_mean[1, 0, timing_mean[1, 0] < 1000]
255+
KERNEL = timing_mean[2, 0, timing_mean[2, 0] < 1000]
256+
NIPALS = timing_mean[3, 0, timing_mean[3, 0] < 1000]
257+
SIMPLS = timing_mean[4, 0, timing_mean[4, 0] < 1000]
258+
259+
plt.figure(figsize=(6, 4))
260+
plt.plot(Ade4, 'b--', label=r'Ade4 ($N>P$)')
261+
plt.plot(UNIPALS, 'c', label='UNIPALS')
262+
plt.plot(KERNEL, 'g', label='KERNEL')
263+
plt.plot(NIPALS, 'r', label='NIPALS')
264+
plt.plot(SIMPLS, 'm', label='SIMPLS\n(Non-Multiblock)')
265+
plt.legend(fontsize=13, loc=(0.1, 0.45))
266+
plt.xlabel(r'Number of samples $N$ in $\boldsymbol{X}$', fontsize=14)
267+
plt.ylabel('Time in seconds', fontsize=14)
268+
plt.ylim((0, 15))
269+
plt.xlim(0, 199)
270+
xticks = np.arange(-1, 200, 50)
271+
xticks[0] = -1
272+
xlabels = xticks*100 + 100
273+
xlabels[0] = 100
274+
plt.xticks(xticks, xlabels, fontsize=13)
275+
plt.yticks(fontsize=13)
276+
plt.tight_layout()
277+
plt.show()

paper/benchmark/runtime_analysis_symmetric.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ def mbpls_ade4(data, num_comp=20):
7272
# Calculation Measurements
7373
include_timing = True
7474

75+
# Plot timing graphs in the end
76+
plot_results = True
77+
7578
# Datasets
7679
x_sizes = np.arange(100, 20001, 100)
7780
y_sizes = np.arange(100, 20001, 100)
@@ -234,3 +237,36 @@ class bcolors:
234237
pickle.dump(indicator_matrix_shared, open('indicator_matrix_symmetric.pkl', 'wb'))
235238
pickle.dump(timing_results_shared, open('timing_results_symmetric.pkl', 'wb'))
236239

240+
# Generate plot as shown in Figure 2b in the paper
241+
if plot_results:
242+
import matplotlib
243+
matplotlib.rc('text', usetex=True)
244+
matplotlib.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath}"]
245+
import matplotlib.pyplot as plt
246+
247+
timing_mean = timing_results.mean(axis=3)
248+
249+
# Only include those results with runtimes lower than 1000 seconds in average
250+
Ade4 = timing_mean[0, 0, timing_mean[0, 0] < 1000]
251+
UNIPALS = timing_mean[1, 0, timing_mean[1, 0] < 1000]
252+
KERNEL = timing_mean[2, 0, timing_mean[2, 0] < 1000]
253+
NIPALS = timing_mean[3, 0, timing_mean[3, 0] < 1000]
254+
SIMPLS = timing_mean[4, 0, timing_mean[4, 0] < 1000]
255+
256+
plt.figure(figsize=(6, 4))
257+
plt.plot(Ade4, 'b', label='Ade4')
258+
plt.plot(UNIPALS, 'c', label='UNIPALS')
259+
plt.plot(KERNEL, 'g', label='KERNEL')
260+
plt.plot(NIPALS, 'r', label='NIPALS')
261+
plt.plot(SIMPLS, 'm', label='SIMPLS\n(Non-Multiblock)')
262+
plt.legend(fontsize=13)
263+
plt.xlabel(r'Total number of samples $N$ and variables $P$ in $\boldsymbol{X}$', fontsize=14)
264+
plt.ylabel('Time in seconds', fontsize=14)
265+
xticks = np.arange(-1, 200, 50)
266+
xticks[0] = 0
267+
plt.xticks(xticks, xticks * 100 + 100, fontsize=13)
268+
plt.yticks(fontsize=13)
269+
plt.ylim(0, 400)
270+
plt.xlim(0, 200)
271+
plt.tight_layout()
272+
plt.show()

0 commit comments

Comments
 (0)