Skip to content

Commit

Permalink
Merge pull request #5 from jdtuck/fix_main
Browse files Browse the repository at this point in the history
remove main from package
  • Loading branch information
dfrancom authored May 8, 2023
2 parents ac77270 + e33020b commit 6dd855e
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions pyBASS/pyBASS.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,50 +894,4 @@ def bassPCA(xx, y, npc=None, percVar=99.9, ncores=1, center=True, scale=False, *
return BassBasis(xx, y, basis, newy, setup.y_mean, setup.y_sd, trunc_error, ncores, **kwargs)


######################################################
## test it out

if __name__ == '__main__':

if False:
def f(x):
return (10 * np.sin(2 * np.pi * x[:, 0] * x[:, 1]) +
20 * (x[:, 2] - .5) ** 2 +
10 * x[:, 3] + 5 * x[:, 4])

n, p = 500, 10
x = np.random.rand(n, p)
xx = np.random.rand(1000, p)
y = f(x) + np.random.normal(size=n)

mod = bass(x, y, nmcmc=10000, nburn=9000)
pred = mod.predict(xx, mcmc_use=np.array([1, 100]), nugget=True)

mod.plot()

print(np.var(mod.predict(xx).mean(axis=0)-f(xx)))

if False:
def f2(x):
return (10 * np.sin(np.pi * tt * x[1]) +
20 * (x[2] - .5) ** 2 +
10 * x[3] + 5 * x[4])

tt = np.linspace(0, 1, 50)
n, p = 500, 9
x = np.random.rand(n, p) - .5
xx = np.random.rand(1000, p) - .5
e = np.random.normal(size=n * len(tt))
y = np.apply_along_axis(f2, 1, x) # + e.reshape(n,len(tt))

modf = bassPCA(x, y, ncores=2, percVar=99.99)
modf.plot()

pred = modf.predict(xx, mcmc_use=np.array([1,100]), nugget=True)

ind = 11
plt.plot(pred[:,ind,:].T)
plt.plot(f2(xx[ind,]),'bo')

plt.plot(np.apply_along_axis(f2, 1, xx), np.mean(pred,axis=0))
abline(1,0)

0 comments on commit 6dd855e

Please sign in to comment.