def show_iteration(results, iteration_to_show, exp=False, drop_outliers=False):
    y_test = results['iterations_results'][iteration_to_show]['test_labels']
    y_pred = results['iterations_results'][iteration_to_show]['pred_labels']
    y_pred_lower = results['iterations_results'][iteration_to_show]['uncertainty_low']
    y_pred_upper = results['iterations_results'][iteration_to_show]['uncertainty_high']
    p = y_test.argsort()
    if drop_outliers:
        q = np.quantile(y_test, 0.97)
        print(q)
        out_mask = (y_test < q)
        print(out_mask.shape)
        y_test = y_test[out_mask]
        y_pred = y_pred[out_mask]
        y_pred_lower = y_pred_lower[out_mask]
        y_pred_upper = y_pred_upper[out_mask]
        p = y_test.argsort()
    (fig, ax) = plt.subplots(figsize=(6, 3))
    if exp:
        y_test = np.exp(y_test)
        y_pred = np.exp(y_pred)
        y_pred_lower = np.exp(y_pred_lower)
        y_pred_upper = np.exp(y_pred_upper)
        if drop_outliers:
            new_r2 = r2_score(y_test, y_pred)
            print('NEW R2 without outliers:', new_r2)
        ax.plot(y_test[p], marker='.', linewidth=1, label='Real', color='#777777', alpha=0.5)
        ax.errorbar(np.arange(len(y_pred)), y_pred[p], yerr=np.array([(y_pred[p] - y_pred_lower[p]), (y_pred_upper[p] - y_pred[p])]), linewidth=0.5, fmt='.', color='#ff7f0e', label='Pred. + Interval', alpha=0.5)
        ax.set_ylabel('Exec. Time [ms]')
        ax.set_xlabel('Non-executed Jobs')
        ax.legend()
        print(results['test_scores_exp'][iteration_to_show])
    else:
        ax.plot(y_test[p], marker='.', linewidth=1, label='Real', color='#777777', alpha=0.5)
        ax.errorbar(np.arange(len(y_pred)), y_pred[p], yerr=np.array([(y_pred[p] - y_pred_lower[p]), (y_pred_upper[p] - y_pred[p])]), linewidth=0.5, fmt='.', color='#ff7f0e', label='Pred. + Interval', alpha=0.5)
        ax.set_ylabel('Log(Exec. Time)')
        ax.set_xlabel('Non-executed Jobs')
        ax.legend()
        print(results['test_scores'][iteration_to_show])
    return ax
def show_iteration(results, iteration_to_show, exp=False, drop_outliers=False):
    y_test = results['iterations_results'][iteration_to_show]['test_labels']
    y_pred = results['iterations_results'][iteration_to_show]['pred_labels']
    y_pred_lower = results['iterations_results'][iteration_to_show]['uncertainty_low']
    y_pred_upper = results['iterations_results'][iteration_to_show]['uncertainty_high']
    p = y_test.argsort()
    if drop_outliers:
        q = np.quantile(y_test, 0.97)
        print(q)
        out_mask = (y_test < q)
        print(out_mask.shape)
        y_test = y_test[out_mask]
        y_pred = y_pred[out_mask]
        y_pred_lower = y_pred_lower[out_mask]
        y_pred_upper = y_pred_upper[out_mask]
        p = y_test.argsort()
    (fig, ax) = plt.subplots(figsize=(6, 3))
    if exp:
        y_test = np.exp(y_test)
        y_pred = np.exp(y_pred)
        y_pred_lower = np.exp(y_pred_lower)
        y_pred_upper = np.exp(y_pred_upper)
        if drop_outliers:
            new_r2 = r2_score(y_test, y_pred)
            print('NEW R2 without outliers:', new_r2)
        ax.plot(y_test[p], marker='.', linewidth=1, label='Real', color='#777777', alpha=0.5)
        ax.errorbar(np.arange(len(y_pred)), y_pred[p], yerr=np.array([(y_pred[p] - y_pred_lower[p]), (y_pred_upper[p] - y_pred[p])]), linewidth=0.5, fmt='.', color='#ff7f0e', label='Pred. + Interval', alpha=0.5)
        ax.set_ylabel('Exec. Time [ms]')
        ax.set_xlabel('Non-executed Jobs')
        ax.legend()
        print(results['test_scores_exp'][iteration_to_show])
    else:
        ax.plot(y_test[p], marker='.', linewidth=1, label='Real', color='#777777', alpha=0.5)
        ax.errorbar(np.arange(len(y_pred)), y_pred[p], yerr=np.array([(y_pred[p] - y_pred_lower[p]), (y_pred_upper[p] - y_pred[p])]), linewidth=0.5, fmt='.', color='#ff7f0e', label='Pred. + Interval', alpha=0.5)
        ax.set_ylabel('Log(Exec. Time)')
        ax.set_xlabel('Non-executed Jobs')
        ax.legend()
        print(results['test_scores'][iteration_to_show])
    return ax