Exemple #1
0
def cov_timing(cv_dir, lscale, order, n_azi_buckets):
    sgp = SparseGP(fname=os.path.join(cv_dir, "fold_00.gp%d_%d_%d" % (lscale, order, n_azi_buckets)))
    X = np.loadtxt(os.path.join(cv_dir, "X.txt"))
    test_idx = np.array([int(z) for z in np.loadtxt(os.path.join(cv_dir, "fold_00_test.txt"))])
    testX = X[test_idx]
    resultfile = os.path.join(cv_dir, "results_gp%d_%d_%d.txt" % (lscale, order, n_azi_buckets))
    errorfile = os.path.join(cv_dir, "error_gp%d_%d_%d.npz" % (lscale, order, n_azi_buckets))
    eval_gp(gp=sgp, testX=testX, resultfile=resultfile, errorfile=errorfile)

    poly = LinearBasisModel(fname=os.path.join(cv_dir, "fold_00.poly_%d_%d" % (order, n_azi_buckets)))
    resultfile_poly = os.path.join(cv_dir, "results_poly_%d_%d.txt" % (order, n_azi_buckets))
    f = open(resultfile_poly, 'w')
    test_n = len(test_idx)
    poly_covars = np.zeros((test_n,))
    t0 = time.time()
    for i in range(test_n):
        poly_covars[i] = poly.covariance(testX[i:i+1,:])
    t1 = time.time()
    f.write("cov time %f\n" % ((t1-t0)/test_n))
    f.close()
Exemple #2
0
def get_nstd(X, y, order, n_azi_buckets, param_var):
    basisfns, b, B = setup_azi_basisfns(order, n_azi_buckets, param_var)
    lbm1 = LinearBasisModel(X=X, y=y, basisfns = basisfns, param_mean=b, param_covar=B, noise_std=1.0, sta="FITZ")
    pred = lbm1.predict(X)
    nstd = np.std(y-pred)
    return nstd