def new_descriptor_performance_plot(fig, max_overview, selection, method, glomeruli=[], descriptor_plot_type='scatterplot'): """compare performance of different descriptors for several glomeruli""" desc_names = max_overview[method][selection]['desc_names'] if 'p_selection' in max_overview[method][selection] and \ np.sum(max_overview[method][selection]['p_selection']) != 0.0: print('plotting param selection instead of maximum') data = max_overview[method][selection]['p_selection'] else: data = max_overview[method][selection]['max'] # use only selected glomeruli avail_glomeruli = max_overview[method][selection]['glomeruli'] if glomeruli: glom_idx = [i for i, g in enumerate(avail_glomeruli) if g in glomeruli] data = data[:, glom_idx] # compute colors to color all glomeruli according to their all performance all_idx = max_overview[method][selection]['desc_names'].index('all') all_values = data[all_idx] n_val = float(len(all_values)-1) clist_all = [sorted(all_values,reverse=True).index(i) / n_val for i in all_values] ax = fig.add_subplot(111) if descriptor_plot_type == 'boxplot': _descriptor_boxplot(ax, data, desc_names) elif descriptor_plot_type == 'scatterplot': _descriptor_scatterplot(ax, data, clist_all, desc_names) elif descriptor_plot_type == 'curveplot': _descriptor_curveplot(ax, data, desc_names) if i_meth == 1: ax.legend(prop={'size':5}) elif descriptor_plot_type == 'violinplot': _violin_boxplot(ax, data, desc_names) else: assert False utils.simple_axis(ax) ax.set_ylabel('q2 score')
desc_idx1 = max_overview['svr']['linear']['desc_names'].index(desc) desc_idx2 = max_overview['forest']['forest']['desc_names'].index(desc) desc1_collect.extend(max_overview['svr']['linear']['p_selection'][desc_idx1, :]) desc2_collect.extend(max_overview['forest']['forest']['p_selection'][desc_idx2, :]) ax.plot(max_overview['svr']['linear']['p_selection'][desc_idx1, :], max_overview['forest']['forest']['p_selection'][desc_idx2, :], 'o', mfc=markers[i], label=desc, markersize=5) ax.plot([0, 0.8], [0, 0.8], color='0.5') plt.axis('scaled') ax.set_xlim([0, .9]) ax.set_ylim([0, .9]) ax.set_xlabel('SVR (q2)') ax.set_ylabel('RFR (q2)') utils.simple_axis(ax) ax.legend(loc='upper left', numpoints=1, frameon=False, prop={'size': 'small'}, bbox_to_anchor=(0.01, 1)) ticks = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] ticklabels = ['0', '', '.2', '', '.4', '', '.6', '', '.8', ''] ax.set_yticks(ticks) ax.set_yticklabels(ticklabels) ax.set_xticks(ticks) ax.set_xticklabels(ticklabels) fig.subplots_adjust(bottom=0.2) fig.tight_layout() fig.savefig(os.path.join(outpath, 'best_method_comparison.' + config['format']), dpi=600) assert len(desc1_collect) == len(desc2_collect) svr_better = np.sum([1 for d1, d2 in zip(desc1_collect, desc2_collect) if d1 > d2]) rfr_better = np.sum([1 for d1, d2 in zip(desc1_collect, desc2_collect) if d1 < d2]) ratio = float(svr_better) / (np.sum(rfr_better) + np.sum(svr_better))