Updates on metric, whitespace
This commit is contained in:
parent
22f6e3284c
commit
7f1f639ee7
|
@ -96,10 +96,11 @@ def procrustes(A, B, strict=True, center=False, verbose=False):
|
|||
else:
|
||||
return b_rot
|
||||
|
||||
def expl_var_x(X, T):
|
||||
"""Returns explained variance of X."""
|
||||
# centered X,Y
|
||||
exp_var_x = diag(dot(T.T, T))*100/(sum(X**2))
|
||||
def expl_var_x(Xc, T):
|
||||
"""Returns explained variance of X.
|
||||
T should carry variance in length, Xc has zero col-mean.
|
||||
"""
|
||||
exp_var_x = diag(dot(T.T, T))*100/(sum(Xc**2))
|
||||
return exp_var_x
|
||||
|
||||
def expl_var_y(Y, T, Q):
|
||||
|
@ -139,14 +140,16 @@ def pls_qvals(a, b, aopt=None, alpha=.3,
|
|||
n_false = zeros((n, n_iter), dtype='<f8')
|
||||
|
||||
#full model
|
||||
if metric!=None:
|
||||
a = dot(a, metric)
|
||||
if algo=='bridge':
|
||||
dat = bridge(a, b, aopt, 'loads', 'fast')
|
||||
else:
|
||||
dat = pls(a, b, aopt, 'loads', 'fast')
|
||||
Wcv = pls_jkW(a, b, aopt, n_blocks=None, algo=algo)
|
||||
Wcv = pls_jkW(a, b, aopt, n_blocks=None, algo=algo, metric=metric)
|
||||
tsq_full = hotelling(Wcv, dat['W'], p_center=p_center,
|
||||
alpha=alpha, crot=crot, strict=strict,
|
||||
cov_center=cov_center, metric=metric)
|
||||
cov_center=cov_center)
|
||||
t0 = time.time()
|
||||
Vs = shuffle_1d(b, n_iter)
|
||||
for i, b_shuff in enumerate(Vs):
|
||||
|
@ -155,10 +158,10 @@ def pls_qvals(a, b, aopt=None, alpha=.3,
|
|||
dat = bridge(a, b_shuff, aopt, 'loads','fast')
|
||||
else:
|
||||
dat = pls(a, b, aopt, 'loads', 'fast')
|
||||
Wcv = pls_jkW(a, b_shuff, aopt, n_blocks=None, algo=algo)
|
||||
Wcv = pls_jkW(a, b_shuff, aopt, n_blocks=None, algo=algo, metric=metric)
|
||||
TSQ[:,i] = hotelling(Wcv, dat['W'], p_center=p_center,
|
||||
alpha=alpha, crot=crot, strict=strict,
|
||||
cov_center=cov_center, metric=metric)
|
||||
cov_center=cov_center)
|
||||
print time.time() - t1
|
||||
sort_index = argsort(tsq_full)[::-1]
|
||||
back_sort_index = sort_index.argsort()
|
||||
|
|
Reference in New Issue