def generate(self, plot: pyplot, data: Any) -> None: # [("gcc", "ref", 184585549)] series: Dict[str, List[float]] = {} for row in data: label = " ".join(row[0:2]) if label not in series: series[label] = [] series[label].append(row[2]) values = list(series.values()) values.sort(key=lambda x: numpy.std(x), reverse=True) keys = list(series.keys()) keys.sort(key=lambda x: numpy.std(series[x]), reverse=True) plot.boxplot(values, showfliers=False) plot.gcf().axes[0].yaxis.get_major_formatter().set_scientific(False) plot.gcf().axes[0].set_xticklabels(keys) plot.title("") plot.ylabel(self.options.event) plot.xlabel("Optimizations")
def generate(self, plot: pyplot, data: Any) -> None: # [("Modern Workstation", "gcc", "ref", 34579902)] series: Dict[str, List[float]] = {} for row in data: label = "{} {}".format(row[1], row[2]) if label not in series: series[label] = [] series[label].append(row[3] / 1e6) values = list(series.values()) values.sort(key=lambda x: min(x), reverse=True) keys = list(series.keys()) keys.sort(key=lambda x: min(series[x]), reverse=True) plot.boxplot(values, showfliers=False) plot.gcf().axes[0].yaxis.get_major_formatter().set_scientific(False) plot.gcf().axes[0].set_xticklabels(keys) plot.title("") plot.ylabel("Duration (ms)") plot.xlabel("Optimizations")
def plot3D(ax: plt, sub3d: plt, X: np.ndarray, y: np.ndarray, w: np.ndarray, name: str) -> None: ''' Visualize decision boundary and data classes in 3D :param ax: matplotlib :param sub3d: fig.add_subplot(XXX, projection='3d') :param X: data :param y: data labels :param w: model parameters :param name: plot name identifier :return: ''' x1 = np.array(X[1, :]) # note: X_train[0,:] is the added row of 1s (bias) x2 = np.array(X[2, :]) posterior1 = LOGREG().activationFunction(w, X) posterior1 = np.squeeze(np.asarray(posterior1)) markers = ['o', '+'] groundTruthLabels = np.unique(y) for li in range(len(groundTruthLabels)): x1_sub = x1[y[:] == groundTruthLabels[li]] x2_sub = x2[y[:] == groundTruthLabels[li]] m_sub = markers[li] posterior1_sub = posterior1[y[:] == groundTruthLabels[li]] sub3d.scatter(x1_sub, x2_sub, posterior1_sub, c=posterior1_sub, vmin=0, vmax=1, marker=m_sub, label='ground truth label = ' + str(li)) ax.legend() x = np.arange(x1.min(), x1.max(), 0.1) pms = [[0.1, 'k:'], [0.25, 'k--'], [0.5, 'r'], [0.75, 'k-.'], [0.9, 'k-']] for (p, m) in pms: yp = (-np.log((1 / p) - 1) - w[1] * x - w[0]) / w[2] yp = np.squeeze(np.asarray(yp)) z = np.ones(yp.shape) * p sub3d.plot(x, yp, z, m, label='p = ' + str(p)) ax.legend() ax.xlabel('feature 1') ax.ylabel('feature 2') ax.title(name + '\n Posterior for class labeled 1')
def plot_choice(num: int, plot: plt, df1: pd.DataFrame) -> None: """ Function to re-draw the canvas :param num: int of the RadioButton selection :param plot: plt Matplotlib.pyplot instance :param df1: pd.DataFrame of the TSA data :return: None """ plot.clf() blue = "#327ff6" gray = "#bdb8b6" if num == 1: # Daily raw pax numbers fig, axis = plt.subplots() axis.plot(df1['Date'], df1['2020'], color=blue, linestyle='-', label="2020") axis.plot(df1['Date'], df1['2019'], color=gray, linestyle='-', label="2019") plot.legend() plot.xlabel('Date') plot.ylabel('Passengers') plot.title('TSA Passenger Daily Throughput 2019 and 2020') axis.get_yaxis().set_major_formatter(FuncFormatter(lambda x, p: format(int(x), ','))) plot_new_canvas(fig, root) elif num == 2: # Weekly raw pax numbers weekly_data = df1.resample('W-Mon', label='right', closed='right', on='Date').sum().reset_index().sort_values(by='Date') fig, axis = plt.subplots() axis.plot(weekly_data['Date'], weekly_data['2020'], color=blue, linestyle='-', label="2020") axis.plot(weekly_data['Date'], weekly_data['2019'], color=gray, linestyle='-', label="2019") axis.get_yaxis().set_major_formatter(FuncFormatter(lambda x, p: format(int(x), ','))) plot.xlabel('Date') plot.ylabel('Passengers') plot.legend() plot.ylim(0, 20E6) plot.title('TSA Passenger Weekly Throughput 2019 and 2020') plot_new_canvas(fig, root) elif num == 3: # Daily YoY percentage fig, axis = plt.subplots() axis.plot(df1['Date'], df1['yoy'], color=blue, linestyle='-', label="2020") plot.legend() plot.xlabel('Date') plot.ylabel('Passenger Load Factor (%)') plot.title('TSA Passenger Daily Throughput in 2020 as a Percentage of 2019') plot_new_canvas(fig, root) elif num == 4: # Weekly YoY percentage weekly_data = df1.resample('W-Mon', label='right', closed='right', on='Date').sum().reset_index().sort_values(by='Date') weekly_data['yoy'] = (weekly_data['2020']/weekly_data['2019'])*100 fig, axis = plt.subplots() axis.plot(weekly_data['Date'], weekly_data['yoy'], color=blue, linestyle='-', label="2020") plot.xlabel('Date') plot.ylabel('Passenger Load Factor (%)') plot.legend() plot.title('TSA Passenger Daily Throughput in 2020 as a Percentage of 2019') plot_new_canvas(fig, root)
def generate(self, plot: pyplot, data: Any) -> None: # [('low-end-laptop', 0, 'mceliece', '6960119f', 'clang', 'ref-optimized', 'keypair', 666.1022, 999, 665165462)] # clang, ref-optimized: [1, 2, 3, ...] series: Dict[str, Dict[int, float]] = {} # run_index: average duration baseline_average_durations: Dict[int, int] = {} # label: run_index: iteration: duration sum_per_label: Dict[str, Dict[int, Dict[int, int]]] = {} # Find values for row in data: compiler = row[4] features = row[5] run_index = row[1] if compiler == "gcc" and features == "ref": average_duration = row[7] baseline_average_durations[run_index] = average_duration else: label = "{} {}".format(compiler, features) if label not in sum_per_label: sum_per_label[label] = {} if run_index not in sum_per_label[label]: sum_per_label[label][run_index] = {} iteration = row[8] duration = row[9] sum_per_label[label][run_index][iteration] = duration baseline_avarage_duration = sum(baseline_average_durations.values() ) / len(baseline_average_durations) print("Baseline runs:", baseline_average_durations) print("Baseline average duration:", baseline_avarage_duration) for label in sum_per_label.keys(): max_length = max([ len(value.items()) for value in sum_per_label[label].values() ]) for i in range(max_length): relevant_items = [ items[i] for items in sum_per_label[label].values() if i in items ] duration = sum(relevant_items) / len(relevant_items) percentual_duration = (duration / 1e6) / baseline_avarage_duration if label not in series: series[label] = {} series[label][i] = (1 / percentual_duration - 1.0) colors = [ "#e6194B", "#3cb44b", "#4363d8", "#f58231", "#800000", "#9A6324", "#000075", "#469990" ] for i, key in enumerate(series.keys()): # TODO: may be wrong if there are gaps in data as it does not care about the acutal indexing values = series[key].values() plot.plot(values, label=key, color=colors[i]) plot.title("") plot.ylabel("Speedup") plot.xlabel("Iteration") plot.legend(bbox_to_anchor=(0.5, 1.05), loc="lower center", fontsize=8, ncol=len(series))