//  [python]
def general_plots(positive_uniques):
    """
    Plots comparing the models' performances
    :param positive_uniques: The positive diseases' IDs in the input data
    :return: Plots exported to the filesystem (default: "export/GENERAL PLOTS")
    """
    save_to = mc.join_save('GENERAL PLOTS')
    mc.make_dir(save_to)
    model_aucs = []
    for model_name in mc.model_names:
        mean_auc = np.mean(
            np.genfromtxt(
                mc.join_save(os.path.join('A', 'A', model_name, 'data', 'aucs.csv'))))
        model_aucs.append([model_name, mean_auc, 'A', 'A', True])
    for tested_on in positive_uniques:
        for trained_on in positive_uniques:
            for model_name in mc.model_names:
                mean_auc = np.mean(np.genfromtxt(
                    mc.join_save(os.path.join(tested_on, trained_on, model_name, 'data', 'aucs.csv'))))
                model_aucs.append([model_name, mean_auc, trained_on, tested_on, trained_on == tested_on])
    model_aucs_df = pd.DataFrame(model_aucs, columns=['Model', 'AUC', 'Train Data', 'Test Data', 'Train/Test equality'])
    average_model_aucs = list()
    for model_name in mc.model_names:
        average_model_aucs.append(np.mean(model_aucs_df['AUC'].loc[model_aucs_df['Model'] == model_name]))
    order_by = [mc.model_names[i] for i in np.argsort(average_model_aucs)[::-1]]
    sns.catplot(data=model_aucs_df, x='Model', y='AUC', kind='swarm', order=order_by, hue='Train/Test equality')
    sns.boxplot(data=model_aucs_df, x='Model', y='AUC', order=order_by, showcaps=False, boxprops={'facecolor': 'None'},
                whiskerprops={'linewidth': 0})
    plt.xticks(fontsize=8)
    plt.title('Model comparison (all validations)')
    mc.write_plot(save_to, 'model_comparison_auc')
    np.savetxt(os.path.join(save_to, 'average_model_aucs.csv'),
               np.array([mc.model_names, average_model_aucs]),
               delimiter=',', fmt='%s')

    max_auc_annot = model_aucs_df[['Train Data', 'Test Data', 'AUC']].copy().fillna(0)
    max_auc_annot = max_auc_annot.loc[max_auc_annot['Train Data'] != 'A'].loc[max_auc_annot['Test Data'] != 'A']
    max_auc_annot = max_auc_annot.loc[max_auc_annot.groupby(['Train Data', 'Test Data'])['AUC'].idxmax()]
    max_auc_annot = max_auc_annot.pivot(index='Train Data', columns='Test Data', values='AUC')

    max_auc = model_aucs_df[['Train Data', 'Test Data', 'AUC']].copy().dropna()
    max_auc = max_auc.loc[max_auc['Train Data'] != 'A'].loc[max_auc['Test Data'] != 'A']
    max_auc = max_auc.loc[max_auc.groupby(['Train Data', 'Test Data'])['AUC'].idxmax()]
    max_auc = max_auc.pivot(index='Train Data', columns='Test Data', values='AUC')

    sns.heatmap(max_auc, cmap='viridis', vmin=0.4, vmax=1)
    for i, col in enumerate(max_auc.columns):
        for j, row in enumerate(max_auc.columns):
            plt.annotate(str(round(max_auc_annot[row][col], 2) if max_auc_annot[row][col] != 0 else 'NaN'),
                         xy=(j + 0.5, i + 0.5),
                         ha='center', va='center', color='white' if max_auc_annot[row][col] != 0 else 'black')
    plt.title('AUCs of most accurate model for each train/test data')
    mc.write_plot(save_to, 'correlation_heatmap_auc')

    max_auc = model_aucs_df[['Train Data', 'Test Data', 'Model', 'AUC']].copy().dropna()
    max_auc = max_auc.loc[max_auc['Train Data'] != 'A'].loc[max_auc['Test Data'] != 'A']
    max_auc = max_auc.loc[max_auc.groupby(['Train Data', 'Test Data'])['AUC'].idxmax()]
    max_auc = max_auc.drop('AUC', axis=1).pivot(index='Train Data', columns='Test Data', values='Model')
    sns.heatmap(max_auc.replace(order_by[::-1], list(range(1, 6))), cbar=False, cmap='tab10')
    for i, col in enumerate(max_auc.columns):
        for j, row in enumerate(max_auc.columns):
            plt.annotate(
                (mc.model_names_dict[max_auc[row][col]] if not str(
                    max_auc[row][col]) == 'nan' else 'N/A'),
                xy=(j + 0.5, i + 0.5),
                ha='center', va='center', color='white' if not str(max_auc[row][col]) == 'nan' else 'black')
    plt.title('Most accurate model for each train/test data (AUC)')
    mc.write_plot(save_to, 'correlation_heatmap_models_auc')

    model_pr_aucs = []
    for model_name in mc.model_names:
        mean_pr_auc = np.mean(
            np.genfromtxt(
                mc.join_save(os.path.join('A', 'A', model_name, 'data', 'pr_aucs.csv'))))
        model_pr_aucs.append([model_name, mean_pr_auc, 'A', 'A', True])
    for tested_on in positive_uniques:
        for trained_on in positive_uniques:
            for model_name in mc.model_names:
                mean_pr_auc = np.mean(np.genfromtxt(
                    mc.join_save(
                        os.path.join(tested_on, trained_on, model_name, 'data', 'pr_aucs.csv'))))
                model_pr_aucs.append([model_name, mean_pr_auc, trained_on, tested_on, trained_on == tested_on])
    model_pr_aucs_df = pd.DataFrame(model_pr_aucs,
                                    columns=['Model', 'PR AUC', 'Train Data', 'Test Data', 'Train/Test equality'])
    average_model_pr_aucs = list()
    for model_name in mc.model_names:
        average_model_pr_aucs.append(np.mean(model_pr_aucs_df['PR AUC'].loc[model_pr_aucs_df['Model'] == model_name]))
    pr_order_by = [mc.model_names[i] for i in np.argsort(average_model_pr_aucs)[::-1]]
    sns.catplot(data=model_pr_aucs_df, x='Model', y='PR AUC', kind='swarm', order=pr_order_by,
                hue='Train/Test equality')
    sns.boxplot(data=model_pr_aucs_df, x='Model', y='PR AUC', order=pr_order_by, showcaps=False,
                boxprops={'facecolor': 'None'},
                whiskerprops={'linewidth': 0})
    plt.xticks(fontsize=8)
    plt.title('Model comparison (all validations)')
    mc.write_plot(save_to, 'model_comparison_pr_auc')
    np.savetxt(os.path.join(save_to, 'average_model_pr_aucs.csv'),
               np.array([mc.model_names, average_model_pr_aucs]),
               delimiter=',', fmt='%s')

    max_pr_auc_annot = model_pr_aucs_df[['Train Data', 'Test Data', 'PR AUC']].copy().fillna(0)
    max_pr_auc_annot = max_pr_auc_annot.loc[max_pr_auc_annot['Train Data'] != 'A'].loc[
        max_pr_auc_annot['Test Data'] != 'A']
    max_pr_auc_annot = max_pr_auc_annot.loc[max_pr_auc_annot.groupby(['Train Data', 'Test Data'])['PR AUC'].idxmax()]
    max_pr_auc_annot = max_pr_auc_annot.pivot(index='Train Data', columns='Test Data', values='PR AUC')

    max_pr_auc = model_pr_aucs_df[['Train Data', 'Test Data', 'PR AUC']].copy().dropna()
    max_pr_auc = max_pr_auc.loc[max_pr_auc['Train Data'] != 'A'].loc[max_pr_auc['Test Data'] != 'A']
    max_pr_auc = max_pr_auc.loc[max_pr_auc.groupby(['Train Data', 'Test Data'])['PR AUC'].idxmax()]
    max_pr_auc = max_pr_auc.pivot(index='Train Data', columns='Test Data', values='PR AUC')

    sns.heatmap(max_pr_auc, cmap='viridis', vmin=0.4, vmax=1)
    for i, col in enumerate(max_pr_auc.columns):
        for j, row in enumerate(max_pr_auc.columns):
            plt.annotate(str(round(max_pr_auc_annot[row][col], 2) if max_pr_auc_annot[row][col] != 0 else 'NaN'),
                         xy=(j + 0.5, i + 0.5),
                         ha='center', va='center', color='white' if max_pr_auc_annot[row][col] != 0 else 'black')
    plt.title('PR AUCs of most accurate model for each train/test data')
    mc.write_plot(save_to, 'correlation_heatmap_pr_auc')

    max_pr_auc = model_pr_aucs_df[['Train Data', 'Test Data', 'Model', 'PR AUC']].copy().dropna()
    max_pr_auc = max_pr_auc.loc[max_pr_auc['Train Data'] != 'A'].loc[max_pr_auc['Test Data'] != 'A']
    max_pr_auc = max_pr_auc.loc[max_pr_auc.groupby(['Train Data', 'Test Data'])['PR AUC'].idxmax()]
    max_pr_auc = max_pr_auc.drop('PR AUC', axis=1).pivot(index='Train Data', columns='Test Data', values='Model')
    sns.heatmap(max_pr_auc.replace(order_by[::-1], list(range(1, 6))), cbar=False, cmap='tab10')
    for i, col in enumerate(max_pr_auc.columns):
        for j, row in enumerate(max_pr_auc.columns):
            plt.annotate(
                (mc.model_names_dict[max_pr_auc[row][col]] if not str(
                    max_pr_auc[row][col]) == 'nan' else 'N/A'),
                xy=(j + 0.5, i + 0.5),
                ha='center', va='center', color='white' if not str(max_pr_auc[row][col]) == 'nan' else 'black')
    plt.title('Most accurate model for each train/test data (PR AUC)')
    mc.write_plot(save_to, 'correlation_heatmap_models_pr_auc')