def scatter_gather(items, x_val, y_val, c_val='condition_color'): x, y, c = [], [], [] for i in items: x.append(get_class_value(i, x_val)) y.append(get_class_value(i, y_val)) c.append(get_class_value(i, c_val)) return x, y, c
def data_matrix(self, prop): conditions = default_condition_order[:] values = [] for log in self.all_logs(): val = get_class_value(log, prop) if val is not None: values.append((log.condition, log.condition_rank, val)) data = np.ndarray((4, 4)) for i, cond in enumerate(conditions): for j in range(3): data[i, j] = np.mean([ val for condition, rank, val in values if condition == cond and rank == j + 1 ]) data[i, 3] = np.mean( [val for condition, _, val in values if condition == cond]) for j in range(3): data[3, j] = np.mean( [val for _, rank, val in values if rank == j + 1]) data[3, 3] = np.mean([val for _, _, val in values]) t = PrettyTable(['', '1', '2', '3', 'M']) conditions += ['M'] for i, row in enumerate(data): t.add_row([conditions[i]] + list(row)) t.float_format = ".3" print(t)
def plot_avg_vs_vp_id(self, prop, show=True): data = {} for vp in self.vps: data[vp.vp_id] = np.mean( [get_class_value(log, prop) for log in vp.logs]) plt.plot(range(len(data)), [d[1] for d in sorted(data.items())]) show_plot(show)
def boxplot_all(self, prop, show=None, fig=None): values, data = {}, [] for log in self.all_logs(filter_5=True): val = get_class_value(log, prop) if val is not None: values.setdefault(log.condition, []).append(val) conditions = EcoSonic_VP.condition_order_from_vp_id(1) data = [values[cond] for cond in conditions] boxplot(data, conditions, prop, 'condition', show, fig)
def data_vs_run(self, prop, global_run_counter=False): max_items = 12 if global_run_counter else 4 data = defaultdict(lambda: [[] for _ in range(max_items)]) for log in self.all_logs(): val = get_class_value(log, prop) if val is not None: idx = log.global_run_counter if global_run_counter else log.run assert idx <= max_items data[log.condition][idx - 1].append(val) return data, max_items