Exemplo n.º 1
0
def PlotPossibleGeoSpace(figname, Xpred_dir, compare_original=False):
    """
    Function to plot the possible geometry space for a model evaluation result.
    It reads from Xpred_dir folder and finds the Xpred result insdie and plot that result
    :params figname: The name of the figure to save
    :params Xpred_dir: The directory to look for Xpred file which is the source of plotting
    :output A plot containing 4 subplots showing the 8 geomoetry dimensions
    """
    Xpredfile = os.path.join(Xpred_dir,
                             get_pred_truth_file.get_Xpred(Xpred_dir))
    Xpred = pd.read_csv(Xpredfile, header=None, delimiter=' ').values

    Xtruthfile = os.path.join(Xpred_dir,
                              get_pred_truth_file.get_Xtruth(Xpred_dir))
    Xtruth = pd.read_csv(Xtruthfile, header=None, delimiter=' ').values

    f = plt.figure()
    ax0 = plt.gca()
    print(np.shape(Xpred))
    #print(Xpred)
    plt.title(figname)
    for i in range(4):
        ax = plt.subplot(2, 2, i + 1)
        ax.scatter(Xpred[:, i], Xpred[:, i + 4], label="Xpred")
        if (compare_original):
            ax.scatter(Xtruth[:, i], Xtruth[:, i + 4], label="Xtruth")
        plt.xlabel('h{}'.format(i))
        plt.ylabel('r{}'.format(i))
        plt.xlim(-1, 1)
        plt.ylim(-1, 1)
        plt.legend()
    #plt.title(figname)
    f.savefig(figname + '.png')
Exemplo n.º 2
0
def PlotPossibleGeoSpace(figname,
                         Xpred_dir,
                         compare_original=False,
                         calculate_diversity=None):
    """
    Function to plot the possible geometry space for a model evaluation result.
    It reads from Xpred_dir folder and finds the Xpred result insdie and plot that result
    :params figname: The name of the figure to save
    :params Xpred_dir: The directory to look for Xpred file which is the source of plotting
    :output A plot containing 4 subplots showing the 8 geomoetry dimensions
    """
    Xpredfile = get_pred_truth_file.get_Xpred(Xpred_dir)
    Xpred = pd.read_csv(Xpredfile, header=None, delimiter=' ').values

    Xtruthfile = get_pred_truth_file.get_Xtruth(Xpred_dir)
    Xtruth = pd.read_csv(Xtruthfile, header=None, delimiter=' ').values

    f = plt.figure()
    ax0 = plt.gca()
    print(np.shape(Xpred))
    #print(Xpred)
    #plt.title(figname)
    if (calculate_diversity == 'MST'):
        diversity_Xpred, diversity_Xtruth = calculate_MST(Xpred, Xtruth)
    elif (calculate_diversity == 'AREA'):
        diversity_Xpred, diversity_Xtruth = calculate_AREA(Xpred, Xtruth)

    for i in range(4):
        ax = plt.subplot(2, 2, i + 1)
        ax.scatter(Xpred[:, i], Xpred[:, i + 4], s=3, label="Xpred")
        if (compare_original):
            ax.scatter(Xtruth[:, i], Xtruth[:, i + 4], s=3, label="Xtruth")
        plt.xlabel('h{}'.format(i))
        plt.ylabel('r{}'.format(i))
        plt.xlim(-1, 1)
        plt.ylim(-1, 1)
        plt.legend()
    if (calculate_diversity != None):
        plt.text(-4,
                 3.5,
                 'Div_Xpred = {}, Div_Xtruth = {}, under criteria {}'.format(
                     diversity_Xpred, diversity_Xtruth, calculate_diversity),
                 zorder=1)
    plt.suptitle(figname)
    f.savefig(figname + '.png')