def xval_variable_parameters(res, ncols=2): ndata = len(res.ids) qs = dict(zip(res.q_names, res.q_values)) devices = np.unique(res.devices) indexes = np.unique([n.split('.')[0] for n in res.q_names], return_index=True)[1] all_ps = [[n.split('.')[0] for n in res.q_names][index] for index in sorted(indexes)] ps = [] for i, p in enumerate(all_ps): if np.shape(qs[p + '.mu'])[0] == ndata: ps.append(p) print(ps) if utils.is_empty(ps): print("- No variables parameters: not producing plot") return # Define data and device-dependent colours cdict = dict(zip(devices, sns.color_palette())) # Define geometry and figures nrows = np.ceil(len(ps) / ncols).astype(int) f, axs = pp.subplots(nrows, ncols, sharex=True, figsize=(6 * ncols, 2 * nrows)) f.suptitle('Local parameters', fontsize=14) for i in range(nrows): for j in range(ncols): if nrows > 1: ax = axs[i, j] else: ax = axs[j] if (j + i * ncols) < len(ps): name = ps[j + i * ncols] for di in devices: locs = np.where(res.devices == di) ax.errorbar(res.ids[locs], qs['%s.mu' % name][locs], 1 / qs['%s.prec' % name][locs], fmt='.', color=cdict[di]) ax.set_title(name) if i == (nrows - 1): ax.set_xlabel('Data instance') else: if i > 0: axs[i - 1, j].set_xlabel('Data instance') ax.set_visible(False) if nrows > 1: axs[i, 0].set_ylabel('Parameter value') else: axs[0].set_ylabel('Parameter value') f.tight_layout(rect=(0, 0, 1, 0.97)) sns.despine() return f
def xval_global_parameters(res, ncols=6): ndata = len(res.ids) nfolds = len(res.chunk_sizes) qs = dict(zip(res.q_names, res.q_values)) indexes = np.unique([n.split('.')[0] for n in res.q_names], return_index=True)[1] all_ps = [[n.split('.')[0] for n in res.q_names][index] for index in sorted(indexes)] print(all_ps) ps = [] for i, p in enumerate(all_ps): if p + '.mu' in qs: if np.shape(qs[p + '.mu'])[0] < ndata: ps.append(p) if utils.is_empty(ps): print("- No global parameters: not producing plot") return # Define geometry and figures n = len(ps) if n < ncols: ncols = n nrows = np.ceil(n / ncols).astype(int) f, axs = pp.subplots(nrows, ncols, figsize=(2 * ncols, 2 * nrows)) f.suptitle('Global parameters', fontsize=14) for i in range(nrows): for j in range(ncols): if nrows > 1: ax = axs[i, j] else: ax = axs[j] if (j + i * ncols) < len(ps): name = ps[j + i * ncols] ax.errorbar(np.linspace(1, nfolds, nfolds), qs['%s.mu' % name], 1 / qs['%s.prec' % name], fmt='.') ax.set_title(name) ax.set_xlim([0.5, nfolds + 0.5]) ax.set_xticks(range(1, nfolds + 1)) if i == (nrows - 1): ax.set_xlabel('Fold') else: if i > 0: axs[i - 1, j].set_xlabel('Fold') ax.set_visible(False) if nrows > 1: axs[i, 0].set_ylabel('Parameter value') else: axs[0].set_ylabel('Parameter value') f.tight_layout(rect=(0, 0, 1, 0.96)) sns.despine() return f
def add_connection( self, prompt: str = 'Name this connection:') -> Optional[JiraConnection]: """ Swallows exceptions to allow for errors during JiraProject caching w/out invalidating addition of JiraConnection """ connection_name = get_input(prompt) if is_empty(connection_name): return None url = get_input( 'JIRA url (example: http://issues.apache.org/jira/):').rstrip('/') if is_empty(url): return None user = get_input('JIRA user name:') if is_empty(user): return None password = getpass.getpass() new_jira_connection = JiraConnection(connection_name, url, user, password) self._jira_connections[ new_jira_connection.connection_name] = new_jira_connection print( 'Must locally cache at least one project\'s JIRA history. Please select a project.' ) new_jira_connection.cache_new_jira_project(self) try: while True: if not is_yes('Add another project?'): break new_jira_connection.cache_new_jira_project(self) except (JIRAError, IOError): print( 'Encountered exception processing JiraProjects. Saving base JiraConnection' ) traceback.print_exc() self._save_config() return new_jira_connection