Added center option to validation, + naming updates
This commit is contained in:
parent
29509902df
commit
e716db3fd2
@ -119,7 +119,7 @@ def pca_cv_val(a, amax, n_sets):
|
||||
aopt = find_aopt_from_sep(sep)
|
||||
return sep, aopt
|
||||
|
||||
def pls_jkW(a, b, amax, n_blocks=None, algo='pls', use_pack=True):
|
||||
def pls_jkW(a, b, amax, n_blocks=None, algo='pls', use_pack=False, center=True):
|
||||
""" Returns CV-segments of paramter W for wide X.
|
||||
|
||||
todo: add support for T,Q and B
|
||||
@ -127,23 +127,26 @@ def pls_jkW(a, b, amax, n_blocks=None, algo='pls', use_pack=True):
|
||||
if n_blocks == None:
|
||||
n_blocks = b.shape[0]
|
||||
|
||||
WW = empty((n_blocks, a.shape[1], amax), dtype='f')
|
||||
Wcv = empty((n_blocks, a.shape[1], amax), dtype='f')
|
||||
|
||||
if use_pack:
|
||||
u, s, inflater = svd(a, full_matrices=0)
|
||||
a = u*s
|
||||
V = pls_gen(a, b, n_blocks=n_blocks)
|
||||
|
||||
V = pls_gen(a, b, n_blocks=n_blocks, center=center)
|
||||
for nn,(a_in, a_out, b_in, b_out) in enumerate(V):
|
||||
if algo=='pls':
|
||||
dat = pls(a_in, b_in, amax, 'loads', 'fast')
|
||||
elif algo=='bridge':
|
||||
dat = bridge(a_in, b_in, amax, 'loads', 'fast')
|
||||
W = dat['W']
|
||||
|
||||
if use_pack:
|
||||
W = dot(inflater.T, W)
|
||||
WW[nn,:,:] = W
|
||||
|
||||
Wcv[nn,:,:] = W
|
||||
|
||||
return WW
|
||||
return Wcv
|
||||
|
||||
def pca_jkP(a, aopt, n_blocks=None):
|
||||
"""Returns loading from PCA on CV-segments.
|
||||
|
Reference in New Issue
Block a user