Added explained variance
This commit is contained in:
+22
-13
@@ -328,11 +328,11 @@ class PLS(Model):
|
||||
**options.make_model_options())
|
||||
# variance captured
|
||||
var_x, exp_var_x = variances(self.model['E0'], self.model['T'], self.model['P'])
|
||||
self.model['var_x'] = var_x
|
||||
self.model['evx'] = var_x
|
||||
self.model['exp_var_x'] = exp_var_x
|
||||
|
||||
var_y, exp_var_y = variances(self.model['F0'], self.model['T'], self.model['Q'])
|
||||
self.model['var_y'] = var_y
|
||||
self.model['evy'] = var_y
|
||||
self.model['exp_var_y'] = exp_var_y
|
||||
|
||||
if options['calc_conf']:
|
||||
@@ -478,6 +478,14 @@ class LPLS(Model):
|
||||
self._data['Z'] = c.asarray()
|
||||
self.validation(options)
|
||||
self.make_model(options)
|
||||
print self.model['evx']
|
||||
evx_str = [str(i)[:3] for i in self.model['evx']]
|
||||
logger.log('notice', 'Explained variance:X\n\t: ' + str(evx_str))
|
||||
evy_str = [str(i)[:3] for i in self.model['evy']]
|
||||
logger.log('notice', 'Explained variance:Y\n\t: ' + str(evy_str))
|
||||
evz_str = [str(i)[:3] for i in self.model['evz']]
|
||||
logger.log('notice', 'Explained variance:Z\n\t: ' + str(evz_str))
|
||||
|
||||
if options['calc_conf']:
|
||||
self.confidence(options)
|
||||
|
||||
@@ -592,7 +600,7 @@ class PlsOptions(Options):
|
||||
opt['center_mth'] = mat_center
|
||||
opt['scale'] = 'scores'
|
||||
|
||||
opt['calc_conf'] = False
|
||||
opt['calc_conf'] = True
|
||||
opt['n_sets'] = 7
|
||||
opt['strict'] = True
|
||||
opt['p_center'] = 'med'
|
||||
@@ -607,7 +615,7 @@ class PlsOptions(Options):
|
||||
opt['all_data'] = [('T', 'scores', True),
|
||||
('P', 'loadings', True),
|
||||
('E','residuals', False),
|
||||
('p_tsq', 't2', False),
|
||||
('w_tsq', 't2', True),
|
||||
('rmsep', 'RMSEP', False)
|
||||
]
|
||||
|
||||
@@ -620,10 +628,10 @@ class PlsOptions(Options):
|
||||
(blmplots.PlsCorrelationLoadingPlot, 'Corr. loadings', False)
|
||||
]
|
||||
|
||||
opt['out_data'] = ['T','P', 'p_tsq']
|
||||
opt['out_data'] = ['T','P', 'w_tsq']
|
||||
opt['out_plots'] = [blmplots.PlsScorePlot,blmplots.PlsLoadingPlot,blmplots.LineViewXc]
|
||||
|
||||
opt['out_data'] = None
|
||||
#opt['out_data'] = None
|
||||
|
||||
opt['pack'] = True
|
||||
opt['calc_qvals'] = False
|
||||
@@ -664,17 +672,17 @@ class LplsOptions(Options):
|
||||
opt['engine'] = nipals_lpls
|
||||
opt['mode'] = 'normal' # how much info to calculate
|
||||
opt['amax'] = 10
|
||||
opt['aopt'] = 4
|
||||
opt['xz_alpha'] = 0.5
|
||||
opt['aopt'] = 3
|
||||
opt['xz_alpha'] = 0.4
|
||||
opt['auto_aopt'] = False
|
||||
opt['center'] = True
|
||||
opt['center_mth'] = [2, 2, 1]
|
||||
opt['scale'] = 'scores'
|
||||
opt['calc_conf'] = False
|
||||
opt['calc_conf'] = True
|
||||
opt['n_sets'] = 75
|
||||
opt['strict'] = False
|
||||
opt['p_center'] = 'med'
|
||||
opt['alpha'] = .2
|
||||
opt['alpha'] = .3
|
||||
opt['cov_center'] = 'med'
|
||||
opt['crot'] = True
|
||||
|
||||
@@ -701,13 +709,14 @@ class LplsOptions(Options):
|
||||
(blmplots.LplsZCorrelationPlot, 'Z corr.', True)
|
||||
]
|
||||
|
||||
opt['out_data'] = ['T','P','L','K']
|
||||
opt['out_plots'] = [blmplots.PlsScorePlot,
|
||||
opt['out_data'] = ['T','P','L','K', 'tsqx', 'tsqz']
|
||||
opt['out_plots'] = [blmplots.LplsScorePlot,
|
||||
blmplots.LplsXLoadingPlot,
|
||||
blmplots.LplsZLoadingPlot,
|
||||
blmplots.LplsXCorrelationPlot,
|
||||
blmplots.LplsZCorrelationPlot,
|
||||
blmplots.LineViewXc]
|
||||
blmplots.LineViewXc,
|
||||
blmplots.LplsExplainedVariancePlot]
|
||||
|
||||
#opt['out_data'] = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user