eval_fancy now with noise covariance
@@ -21,7 +21,7 @@ from .noise_ceiling import cv_noise_ceiling
def eval_fancy(model, data, method='cosine', fitter=None,
- k_pattern=5, k_rdm=5, N=1000,
+ k_pattern=5, k_rdm=5, N=1000, boot_noise_ceil=False,
pattern_descriptor=None, rdm_descriptor=None):
"""evaluates a model by k-fold crossvalidation within a bootstrap
Then uses the correction formula to get an estimate of the variance
@@ -59,22 +59,30 @@ def eval_fancy(model, data, method='cosine', fitter=None,
k_pattern=k_pattern, k_rdm=k_rdm, N=N, boot_type='pattern',
pattern_descriptor=pattern_descriptor, rdm_descriptor=rdm_descriptor)
eval_rdm = result_rdm.evaluations
- eval_rdm = eval_rdm[~np.isnan(eval_rdm[:, 0, 0])]
+ ok_rdm = ~np.isnan(eval_rdm[:, 0, 0])
+ eval_rdm = eval_rdm[ok_rdm]
+ nc_rdm = result_rdm.noise_ceiling[:, ok_rdm]
eval_rdm = np.mean(eval_rdm, -1)
- var_rdm = np.cov(eval_rdm.T)
+ var_rdm = np.cov(np.concatenate([eval_rdm.T, nc_rdm]))
eval_pattern = result_pattern.evaluations
- eval_pattern = eval_pattern[~np.isnan(eval_pattern[:, 0, 0])]
+ ok_pattern = ~np.isnan(eval_pattern[:, 0, 0])
+ eval_pattern = eval_pattern[ok_pattern]
+ nc_pattern = result_pattern.noise_ceiling[:, ok_pattern]
eval_pattern = np.mean(eval_pattern, -1)
- var_pattern = np.cov(eval_pattern.T)
+ var_pattern = np.cov(np.concatenate([eval_pattern.T, nc_pattern]))
eval_full = result_full.evaluations
- eval_full = eval_full[~np.isnan(eval_full[:, 0, 0])]
+ ok_full = ~np.isnan(eval_full[:, 0, 0])
+ eval_full = eval_full[ok_full]
+ nc_full = result_full.noise_ceiling[:, ok_full]
eval_full = np.mean(eval_full, -1)
- var_full = np.cov(eval_full.T)
+ var_full = np.cov(np.concatenate([eval_full.T, nc_full]))
var_estimate = 2 * (var_rdm + var_pattern) - var_full
result = Result(model, result_full.evaluations, method=method,
cv_method='fancy',
noise_ceiling=result_full.noise_ceiling,
- variances=var_estimate)
+ variances=var_estimate[:-2, :-2],
+ noise_ceil_var=var_estimate[:, -2:],
+ dof=result_full.dof)
return result
