Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Some .....

This commit is contained in:
Arnar Flatberg 2007-08-07 11:39:16 +00:00
parent 4b80baf225
commit d055a1f882
1 changed files with 12 additions and 20 deletions

View File

@ -171,7 +171,7 @@ class PCA(Model):
self.make_model(**options.make_model_options())
if options['calc_conf']:
self.confidence(**options.confidence_options())
out = [self.as_dataset(p) for p in options['out_data']]
for plt in self.get_out_plots(options):
out.append(plt)
@ -206,6 +206,7 @@ class PLS(Model):
else:
val_engine = pls_val
if self._options['calc_cv']==True:
print "Doing RMSEP calc ..."
rmsep, aopt = val_engine(self.model['E0'], self.model['F0'],
self._options['amax'], self._options['n_sets'])
self.model['rmsep'] = rmsep[:,:-1]
@ -221,6 +222,7 @@ class PLS(Model):
"""
aopt = self.model['aopt']
if self._options['calc_conf']:
print "Doing Tsq"
jk_segments = pls_jkW(self.model['E0'], self.model['F0'],
aopt, n_sets)
Wcal = self.model['W'][:,:aopt]
@ -238,6 +240,7 @@ class PLS(Model):
"""Estimates cut off on significant vars by controlling fdr."""
if self._options['calc_qvals']==True:
print "Doing Qvals"
qvals = pls_qvals(a, b,
aopt=None,
alpha=reg,
@ -253,6 +256,7 @@ class PLS(Model):
def make_model(self, a, b, amax, scale, mode, engine):
"""Make model on amax components.
"""
print "MAking model"
dat = engine(a, b, amax, scale, mode)
self.model.update(dat)
@ -330,18 +334,7 @@ class PLS(Model):
var_y, exp_var_y = variances(self.model['F0'], self.model['T'], self.model['Q'])
self.model['var_y'] = var_y
self.model['exp_var_y'] = exp_var_y
if options['calc_corrloads']:
corr_load = scipy.empty_like(self.model['P'].copy())
T = self.model['T']
X = self._data['X']
# For each variable/attribute in original matrix (not meancentered)
for i,score in enumerate(T.T):
for j, profile in enumerate(X.T):
corrs = scipy.corrcoef(score, profile)
corr_load[j,i] = corrs[0,1]
self.model['CP'] = corr_load
if options['calc_conf']:
self.confidence(**options.confidence_options())
@ -598,13 +591,12 @@ class PlsOptions(Options):
opt['center'] = True
opt['center_mth'] = mat_center
opt['scale'] = 'scores'
opt['calc_corrloads'] = True
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
@ -625,7 +617,7 @@ class PlsOptions(Options):
(blmplots.LineViewXc, 'Line view', True),
(blmplots.PredictionErrorPlot, 'Residual Error', False),
(blmplots.RMSEPPlot, 'RMSEP', False),
(blmplots.PlsCorrelationLoadingPlot, 'Corr. loadings', True)
(blmplots.PlsCorrelationLoadingPlot, 'Corr. loadings', False)
]
opt['out_data'] = ['T','P', 'p_tsq']
@ -673,10 +665,10 @@ class LplsOptions(Options):
opt['mode'] = 'normal' # how much info to calculate
opt['amax'] = 10
opt['aopt'] = 4
opt['xz_alpha'] = .3
opt['xz_alpha'] = 0.5
opt['auto_aopt'] = False
opt['center'] = True
opt['center_mth'] = [2, 0, 1]
opt['center_mth'] = [2, 2, 1]
opt['scale'] = 'scores'
opt['calc_conf'] = False
opt['n_sets'] = 75