Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added center option to validation, + naming updates

This commit is contained in:
Arnar Flatberg 2007-01-31 11:59:23 +00:00
parent 29509902df
commit e716db3fd2
1 changed files with 8 additions and 5 deletions

View File

@ -119,7 +119,7 @@ def pca_cv_val(a, amax, n_sets):
aopt = find_aopt_from_sep(sep) aopt = find_aopt_from_sep(sep)
return sep, aopt 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. """ Returns CV-segments of paramter W for wide X.
todo: add support for T,Q and B 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: if n_blocks == None:
n_blocks = b.shape[0] 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: if use_pack:
u, s, inflater = svd(a, full_matrices=0) u, s, inflater = svd(a, full_matrices=0)
a = u*s 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): for nn,(a_in, a_out, b_in, b_out) in enumerate(V):
if algo=='pls': if algo=='pls':
dat = pls(a_in, b_in, amax, 'loads', 'fast') dat = pls(a_in, b_in, amax, 'loads', 'fast')
elif algo=='bridge': elif algo=='bridge':
dat = bridge(a_in, b_in, amax, 'loads', 'fast') dat = bridge(a_in, b_in, amax, 'loads', 'fast')
W = dat['W'] W = dat['W']
if use_pack: if use_pack:
W = dot(inflater.T, W) W = dot(inflater.T, W)
WW[nn,:,:] = W
Wcv[nn,:,:] = W
return WW return Wcv
def pca_jkP(a, aopt, n_blocks=None): def pca_jkP(a, aopt, n_blocks=None):
"""Returns loading from PCA on CV-segments. """Returns loading from PCA on CV-segments.