Some .....
This commit is contained in:
parent
4b80baf225
commit
d055a1f882
|
@ -171,7 +171,7 @@ class PCA(Model):
|
||||||
self.make_model(**options.make_model_options())
|
self.make_model(**options.make_model_options())
|
||||||
if options['calc_conf']:
|
if options['calc_conf']:
|
||||||
self.confidence(**options.confidence_options())
|
self.confidence(**options.confidence_options())
|
||||||
|
|
||||||
out = [self.as_dataset(p) for p in options['out_data']]
|
out = [self.as_dataset(p) for p in options['out_data']]
|
||||||
for plt in self.get_out_plots(options):
|
for plt in self.get_out_plots(options):
|
||||||
out.append(plt)
|
out.append(plt)
|
||||||
|
@ -206,6 +206,7 @@ class PLS(Model):
|
||||||
else:
|
else:
|
||||||
val_engine = pls_val
|
val_engine = pls_val
|
||||||
if self._options['calc_cv']==True:
|
if self._options['calc_cv']==True:
|
||||||
|
print "Doing RMSEP calc ..."
|
||||||
rmsep, aopt = val_engine(self.model['E0'], self.model['F0'],
|
rmsep, aopt = val_engine(self.model['E0'], self.model['F0'],
|
||||||
self._options['amax'], self._options['n_sets'])
|
self._options['amax'], self._options['n_sets'])
|
||||||
self.model['rmsep'] = rmsep[:,:-1]
|
self.model['rmsep'] = rmsep[:,:-1]
|
||||||
|
@ -221,6 +222,7 @@ class PLS(Model):
|
||||||
"""
|
"""
|
||||||
aopt = self.model['aopt']
|
aopt = self.model['aopt']
|
||||||
if self._options['calc_conf']:
|
if self._options['calc_conf']:
|
||||||
|
print "Doing Tsq"
|
||||||
jk_segments = pls_jkW(self.model['E0'], self.model['F0'],
|
jk_segments = pls_jkW(self.model['E0'], self.model['F0'],
|
||||||
aopt, n_sets)
|
aopt, n_sets)
|
||||||
Wcal = self.model['W'][:,:aopt]
|
Wcal = self.model['W'][:,:aopt]
|
||||||
|
@ -238,6 +240,7 @@ class PLS(Model):
|
||||||
"""Estimates cut off on significant vars by controlling fdr."""
|
"""Estimates cut off on significant vars by controlling fdr."""
|
||||||
|
|
||||||
if self._options['calc_qvals']==True:
|
if self._options['calc_qvals']==True:
|
||||||
|
print "Doing Qvals"
|
||||||
qvals = pls_qvals(a, b,
|
qvals = pls_qvals(a, b,
|
||||||
aopt=None,
|
aopt=None,
|
||||||
alpha=reg,
|
alpha=reg,
|
||||||
|
@ -253,6 +256,7 @@ class PLS(Model):
|
||||||
def make_model(self, a, b, amax, scale, mode, engine):
|
def make_model(self, a, b, amax, scale, mode, engine):
|
||||||
"""Make model on amax components.
|
"""Make model on amax components.
|
||||||
"""
|
"""
|
||||||
|
print "MAking model"
|
||||||
dat = engine(a, b, amax, scale, mode)
|
dat = engine(a, b, amax, scale, mode)
|
||||||
self.model.update(dat)
|
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'])
|
var_y, exp_var_y = variances(self.model['F0'], self.model['T'], self.model['Q'])
|
||||||
self.model['var_y'] = var_y
|
self.model['var_y'] = var_y
|
||||||
self.model['exp_var_y'] = exp_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']:
|
if options['calc_conf']:
|
||||||
self.confidence(**options.confidence_options())
|
self.confidence(**options.confidence_options())
|
||||||
|
|
||||||
|
@ -598,13 +591,12 @@ class PlsOptions(Options):
|
||||||
opt['center'] = True
|
opt['center'] = True
|
||||||
opt['center_mth'] = mat_center
|
opt['center_mth'] = mat_center
|
||||||
opt['scale'] = 'scores'
|
opt['scale'] = 'scores'
|
||||||
|
|
||||||
opt['calc_corrloads'] = True
|
|
||||||
opt['calc_conf'] = False
|
opt['calc_conf'] = False
|
||||||
opt['n_sets'] = 5
|
opt['n_sets'] = 7
|
||||||
opt['strict'] = True
|
opt['strict'] = True
|
||||||
opt['p_center'] = 'med'
|
opt['p_center'] = 'med'
|
||||||
opt['alpha'] = .8
|
opt['alpha'] = .2
|
||||||
opt['cov_center'] = 'med'
|
opt['cov_center'] = 'med'
|
||||||
opt['crot'] = True
|
opt['crot'] = True
|
||||||
|
|
||||||
|
@ -625,7 +617,7 @@ class PlsOptions(Options):
|
||||||
(blmplots.LineViewXc, 'Line view', True),
|
(blmplots.LineViewXc, 'Line view', True),
|
||||||
(blmplots.PredictionErrorPlot, 'Residual Error', False),
|
(blmplots.PredictionErrorPlot, 'Residual Error', False),
|
||||||
(blmplots.RMSEPPlot, 'RMSEP', False),
|
(blmplots.RMSEPPlot, 'RMSEP', False),
|
||||||
(blmplots.PlsCorrelationLoadingPlot, 'Corr. loadings', True)
|
(blmplots.PlsCorrelationLoadingPlot, 'Corr. loadings', False)
|
||||||
]
|
]
|
||||||
|
|
||||||
opt['out_data'] = ['T','P', 'p_tsq']
|
opt['out_data'] = ['T','P', 'p_tsq']
|
||||||
|
@ -673,10 +665,10 @@ class LplsOptions(Options):
|
||||||
opt['mode'] = 'normal' # how much info to calculate
|
opt['mode'] = 'normal' # how much info to calculate
|
||||||
opt['amax'] = 10
|
opt['amax'] = 10
|
||||||
opt['aopt'] = 4
|
opt['aopt'] = 4
|
||||||
opt['xz_alpha'] = .3
|
opt['xz_alpha'] = 0.5
|
||||||
opt['auto_aopt'] = False
|
opt['auto_aopt'] = False
|
||||||
opt['center'] = True
|
opt['center'] = True
|
||||||
opt['center_mth'] = [2, 0, 1]
|
opt['center_mth'] = [2, 2, 1]
|
||||||
opt['scale'] = 'scores'
|
opt['scale'] = 'scores'
|
||||||
opt['calc_conf'] = False
|
opt['calc_conf'] = False
|
||||||
opt['n_sets'] = 75
|
opt['n_sets'] = 75
|
||||||
|
|
Reference in New Issue