Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0
This commit is contained in:
Arnar Flatberg 2007-08-02 11:18:18 +00:00
parent da5b977042
commit 973470b595
2 changed files with 16 additions and 15 deletions

View File

@ -520,22 +520,22 @@ class PcaOptions(Options):
opt['engine'] = pca
opt['mode'] = 'normal' # how much info to calculate
opt['amax'] = 10
opt['aopt'] = 100
opt['aopt'] = 5
opt['auto_aopt'] = False
opt['center'] = True
opt['center_mth'] = mat_center
opt['scale'] = 'scores'
opt['calc_conf'] = False
opt['n_sets'] = 5
opt['n_sets'] = 7
opt['strict'] = True
opt['p_center'] = 'med'
opt['alpha'] = .8
opt['alpha'] = .2
opt['cov_center'] = 'med'
opt['crot'] = True
opt['calc_cv'] = False
opt['calc_pert'] = True
opt['calc_pert'] = False
opt['pert_val_method'] = 'random_diag'
opt['cv_val_method'] = 'random'
opt['cv_val_sets'] = 10
@ -673,16 +673,16 @@ class LplsOptions(Options):
opt['mode'] = 'normal' # how much info to calculate
opt['amax'] = 10
opt['aopt'] = 4
opt['xz_alpha'] = .6
opt['xz_alpha'] = .3
opt['auto_aopt'] = False
opt['center'] = True
opt['center_mth'] = [2, 0, 1]
opt['scale'] = 'scores'
opt['calc_conf'] = True
opt['calc_conf'] = False
opt['n_sets'] = 75
opt['strict'] = False
opt['p_center'] = 'med'
opt['alpha'] = .4
opt['alpha'] = .2
opt['cov_center'] = 'med'
opt['crot'] = True
@ -709,7 +709,7 @@ class LplsOptions(Options):
(blmplots.LplsZCorrelationPlot, 'Z corr.', True)
]
opt['out_data'] = ['T','P', 'tsqx', 'tsqz', 'L','K']
opt['out_data'] = ['T','P','L','K']
opt['out_plots'] = [blmplots.PlsScorePlot,
blmplots.LplsXLoadingPlot,
blmplots.LplsZLoadingPlot,

View File

@ -62,11 +62,12 @@ def pca(a, aopt,scale='scores',mode='normal',center_axis=0):
array([0.,99.8561562, 100.])
"""
m, n = a.shape
assert(aopt<=min(m,n))
if center_axis>=0:
a = a - expand_dims(a.mean(center_axis), center_axis)
m, n = a.shape
if m>(n+100) or n>(m+100):
u, e, v = esvd(a)
u, e, v = esvd(a, amax=None) # fixme:amax option need to work with expl.var
s = sqrt(e)
else:
u, s, vt = svd(a, 0)
@ -696,7 +697,7 @@ def esvd(data, amax=None):
kernel = dot(data.T, data)
if has_sym:
if not amax:
amax = n
amax = n-1
pcrange = [n-amax, n]
s, v = symeig(kernel, range=pcrange, overwrite=True)
s = s[::-1]
@ -705,20 +706,20 @@ def esvd(data, amax=None):
u, s, vt = svd(kernel)
v = vt.T
u = dot(data, v)
for i in xrange(n):
for i in xrange(amax):
s[i] = vnorm(u[:,i])
u[:,i] = u[:,i]/s[i]
else:
kernel = dot(data, data.T)
if has_sym:
if not amax:
amax = m
amax = m-1
pcrange = [m-amax, m]
s, u = symeig(kernel, range=pcrange, overwrite=True)
else:
u, s, vt = svd(kernel)
v = dot(u.T, data)
for i in xrange(m):
v = dot(u.T, data)
for i in xrange(amax):
s[i] = vnorm(v[i,:])
v[i,:] = v[i,:]/s[i]