예제 #1
0
def RetrieveFeaturePredictionNMse(model_name):
    """
    Retrieve the Feature and Prediciton values and place in a np array
    :param model_name: the name of the model
    return Xtruth, Xpred, Ytruth, Ypred
    """
    ##Retrieve the prediction and truth and prediction first
    feature_file = os.path.join('data',
                                'test_Xtruth_{}.csv'.format(model_name))
    pred_file = os.path.join('data', 'test_Ypred_{}.csv'.format(model_name))
    truth_file = os.path.join('data', 'test_Ytruth_{}.csv'.format(model_name))
    feat_file = os.path.join('data', 'test_Xpred_{}.csv'.format(model_name))

    #Getting the files from file name
    Xtruth = pd.read_csv(feature_file, header=None, delimiter=' ')
    Xpred = pd.read_csv(feat_file, header=None, delimiter=' ')
    Ytruth = pd.read_csv(truth_file, header=None, delimiter=' ')
    Ypred = pd.read_csv(pred_file, header=None, delimiter=' ')

    #retrieve mse, mae
    Ymae, Ymse = evaluate.compare_truth_pred(pred_file,
                                             truth_file)  #get the maes of y

    print(Xtruth.shape)
    return Xtruth.values, Xpred.values, Ytruth.values, Ypred.values, Ymae, Ymse
예제 #2
0
import matplotlib
matplotlib.use('agg') 		#To make it silent and dont output image and thus cause error
import matplotlib.pyplot as plt
import numpy as np
import plotsAnalysis
import pandas as pd
import evaluate 
import flag_reader
import os



flags = flag_reader.read_flag()
pred_file = 'data/test_Ypred_20190821_225753.csv'
truth_file = 'data/test_Ytruth_20190821_225753.csv'

mae, mse = evaluate.compare_truth_pred(pred_file, truth_file)
plt.figure(figsize=(12, 6))
plt.hist(mse, bins=100)
plt.xlabel('Mean Squared Error')
plt.ylabel('cnt')
plt.suptitle('Backprop (Avg MSE={:.4e})'.format(np.mean(mse)))
plt.savefig(os.path.join(os.path.abspath(''), 'data',
                             'Backprop_{}.png'.format(flags.model_name)))
plt.show()

plotsAnalysis.SpectrumComparisonNGeometryComparison(3,2, (13,8), flags.model_name, [-1, 1, -1, 1])