From 973470b59537542002e514381f523ae454c73168 Mon Sep 17 00:00:00 2001 From: flatberg Date: Thu, 2 Aug 2007 11:18:18 +0000 Subject: [PATCH] stuff --- fluents/lib/blmfuncs.py | 16 ++++++++-------- fluents/lib/engines.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fluents/lib/blmfuncs.py b/fluents/lib/blmfuncs.py index 619e156..9c629bb 100644 --- a/fluents/lib/blmfuncs.py +++ b/fluents/lib/blmfuncs.py @@ -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, diff --git a/fluents/lib/engines.py b/fluents/lib/engines.py index 0d52917..9990c71 100644 --- a/fluents/lib/engines.py +++ b/fluents/lib/engines.py @@ -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]