def scoring(fname, n, test): # load test data a_test, age_err, age_errp, a_errm, p_test, p_err, bv_test, bv_err, g, g_err, \ g_errp, g_errm, flag = load_dat(fname, test, cv=True) # load parameters from training data data = np.genfromtxt('/Users/angusr/Python/noisy-plane/parameters%s%s.txt'%(n,fname)).T pars = data[0][:3] # calculate score p_pred = period_model(pars, a_test, bv_test, .45) l = np.isfinite(p_pred) n = len(p_pred[l]) # root mean squared error return np.sqrt((np.sum((p_test[l] - p_pred[l])**2))/n)
trains = ['CF45', 'HF45', 'PF45', 'PF5'] tests = ['AHP', 'ACP', 'ACH', 'ACH'] RMS = [] for i in range(len(tests)): # load test data a_test, age_err, age_errp, a_errm, p_test, p_err, bv_test, bv_err, g, g_err, \ g_errp, g_errm, flag = load_dat(tests[i], False, False) print len(p_test) # load parameters from training data data = np.genfromtxt('/Users/angusr/Python/noisy-plane/parameters%s.txt'%trains[i]).T pars = data[0][:3] # calculate score p_pred = period_model(pars, a_test, bv_test, .45) l = np.isfinite(p_pred) n = len(p_pred[l]) # root mean squared error RMS.append(np.sqrt((np.sum(((p_test[l] - p_pred[l])**2)))/n)) # # reduced chi squared # print 'chi', sum(((p_test[l] - p_pred[l])**2)/p_err[l]**2)/n # # # log likelihood L = (.5*np.sum(((p_pred[l] - p_test[l]) / p_err[l])**2)) #- np.log(2*np.pi*n) # print p_err[l] # raw_input('enter') # print 'likelihood = ', L