In [1]:
import numpy as np
import matplotlib.pyplot as plt
% matplotlib inline
import pandas as pd
import itertools
import seaborn
plt.rcParams['figure.figsize'] = (10, 8)
In [2]:
data1 = pd.read_csv("data1.csv")
data1['Example'] = 1
data1.head()
Out[2]:
In [3]:
data2 = pd.read_csv("data2.csv")
data2['Example'] = 2
data2.head()
Out[3]:
In [4]:
data = pd.concat([data1, data2], axis=0, ignore_index=True)
data
Out[4]:
In [5]:
def plot_stuff(grouped, x, field1, field2, xlab="", ylab="", title="", fname="plot.pdf"):
grouped1 = grouped[grouped['Example'] == 1]
grouped2 = grouped[grouped['Example'] == 2]
plt.plot(grouped1[x], grouped1[field1], '-o', label='Example 1 Serial')
plt.plot(grouped1[x], grouped1[field2], '-o', label='Example 1 Parallel')
plt.plot(grouped2[x], grouped2[field1], '-o', label='Example 2 Serial')
plt.plot(grouped2[x], grouped2[field2], '-o', label='Example 2 Parallel')
plt.legend(loc='best', bbox_to_anchor = (1.25,1))
plt.title(title)
plt.ylabel(ylab)
plt.xlabel(xlab)
plt.savefig(fname, bbox_inches="tight")
plt.show()
In [6]:
# plot of runtime vs CPUs
criterion = data['corrections'].isin([2]) & data['qualityfactor'].isin([100])
plt_data = data[criterion]
grouped = plt_data.groupby(['n_procs', 'Example'], as_index=False).aggregate(np.mean)
plot_stuff(grouped, 'n_procs', 'serial_time', 'parallel_time', 'Number of CPUs',
'Wall Clock Time (sec)', 'Runtime vs. CPUs', 'runtime_vs_cpus.pdf')
In [7]:
# plot of runtime vs number of corrections
plt_df = data[data['n_procs'].isin([16]) & data['qualityfactor'].isin([100])]
grouped = plt_df.groupby(['corrections', 'Example'], as_index=False).aggregate(np.mean)
plot_stuff(grouped, 'corrections', 'serial_time', 'parallel_time', 'Number of Corrections',
'Wall Clock Time (sec)', 'Runtime vs. Number of Correction Steps', 'runtime_vs_corrections.pdf')
In [8]:
# plot of accuracy vs number of corrections
plt_df = data[data['n_procs'].isin([32]) & data['qualityfactor'].isin([100])]
grouped = plt_df.groupby(['corrections', 'Example'], as_index=False).aggregate(np.mean)
plot_stuff(grouped, 'corrections', 'serial_mean', 'parallel_mean', 'Number of Corrections',
'Absolute Error', 'Error vs. Number of Correction Steps', 'error_vs_corrections.pdf')
In [9]:
# plot of accuracy vs qualityfactor
plt_df = data[data['n_procs'].isin([32]) & data['corrections'].isin([2])]
grouped = plt_df.groupby(['qualityfactor', 'Example'], as_index=False).aggregate(np.mean)
plot_stuff(grouped, 'qualityfactor', 'serial_mean', 'parallel_mean', 'Quality Factor',
'Absolute Error', 'Error vs. Quality Factor', 'error_vs_qualityfactor.pdf')