linewidth=linewidth)
        plt.title(method_name, fontsize=fontsize)
        legend = plt.legend(LEGEND_NAMES,
                            fontsize=fontsize,
                            bbox_to_anchor=(1, 1),
                            loc=2,
                            borderaxespad=0.)
        plt.xlim([0, 100])
        plt.ylim([0.5, 1])
        plt.xlabel('Number of experiments', fontsize=fontsize)
        plt.ylabel('Prediction accuracy', fontsize=fontsize)
        plt.tight_layout()

        plot_filename = os.path.join(PLOT_FOLDER,
                                     'learning_curve_{}'.format(method_name))
        save_and_close_figure(fig, plot_filename, exts=['.png'], legend=legend)

        ##
        class_names = ['NoCrystal', 'Crystal']
        for iclass, class_name in enumerate(class_names):

            fig = plt.figure(figsize=(12, 8))
            for xp_name in XP_NAMES:
                result_dict = RESULTS[xp_name]
                plt.plot(result_dict['test_range'],
                         result_dict['class_acc'][iclass],
                         linewidth=linewidth)
            plt.title('{} | {}'.format(class_name, method_name),
                      fontsize=fontsize)
            legend = plt.legend(LEGEND_NAMES,
                                fontsize=fontsize,
Пример #2
0
                 AVG_RESULTS['RANDOM'],
                 'b',
                 linestyle='-',
                 linewidth=linewidth,
                 marker='D',
                 markersize=markersize)

        plt.title('Evolution of Crystallization Model Quality',
                  fontsize=fontsize)
        plt.legend(['Algorithm', 'Human', 'Random'], fontsize=fontsize, loc=2)
        plt.xlim([-1, 101])

        if method_name == 'Adaboost':
            plt.ylim([60, 85])
            y_tick_pos = [60, 65, 70, 75, 80, 85]
        else:
            plt.ylim([65, 85])
            y_tick_pos = [65, 70, 75, 80, 85]
        plt.yticks(y_tick_pos, ['{}%'.format(i) for i in y_tick_pos])

        plt.xlabel('Number of Experiments', fontsize=fontsize)
        plt.ylabel('Prediction Accuracy - %', fontsize=fontsize)

        #
        PLOT_FOLDER = os.path.join(HERE_PATH, 'plot')
        filetools.ensure_dir(PLOT_FOLDER)

        plot_filename = os.path.join(
            PLOT_FOLDER, 'learning_curve_unbiased_{}'.format(method_name))
        save_and_close_figure(fig, plot_filename)
Пример #3
0
        fig = plt.figure(figsize=(12, 8))
        all_data = []
        for i, method_name in enumerate(method_names):

            data = results[problem_name][method_name]['accuracy_score']
            data = np.array(data)
            if method_name == 'uncertainty_single':
                data = data[:, 0:-1:10]
            all_data.append(data)

        all_data = np.array(all_data)
        all_data = np.swapaxes(all_data, 0, 1)
        all_data = np.swapaxes(all_data, 1, 2)
        ax = sns.tsplot(all_data,
                        time=range(1, 11),
                        condition=method_names,
                        ci=[68, 95])
        ax.plot([1, 10], [1, 1], color='grey', linestyle='--')
        ax.set_xlabel('Iterations', fontsize=fontsize)
        ax.set_ylabel('Prediction Accuracy', fontsize=fontsize)
        ylim = ax.get_ylim()
        ax.set_ylim([ylim[0], 1 + 0.05 * np.diff(ylim)])
        ax.legend(bbox_to_anchor=(1, 0.35), fontsize=fontsize)
        figures.append(fig)

    #
    for i, fig in enumerate(figures):
        foldername = os.path.join(HERE_PATH, 'plot', problem_names[i])
        filename = os.path.join(foldername, 'accuracy')
        save_and_close_figure(fig, filename, exts=['.png'])