basic fix, inserting nans for unusable samples
@@ -323,6 +323,8 @@ def bootstrap_crossval(model, data, method='cosine', fitter=None,
sample, rdm_sample, pattern_sample = bootstrap_sample(data,
rdm_descriptor=rdm_descriptor,
pattern_descriptor=pattern_descriptor)
+ if len(np.unique(rdm_sample)) >= k_rdm \
+ and len(np.unique(pattern_sample)) >= k_pattern:
train_set, test_set, ceil_set = sets_k_fold(sample,
pattern_descriptor=pattern_descriptor,
rdm_descriptor=rdm_descriptor,
@@ -341,6 +343,12 @@ def bootstrap_crossval(model, data, method='cosine', fitter=None,
elif isinstance(model, Iterable):
evaluations[i_sample, :, :] = cv_result.evaluations[0]
noise_ceil[:,i_sample] = np.mean(cv_result.noise_ceiling, axis=-1)
+ else: # sample does not allow desired crossvalidation
+ if isinstance(model, Model):
+ evaluations[i_sample, 0, :] = np.nan
+ elif isinstance(model, Iterable):
+ evaluations[i_sample, :, :] = np.nan
+ noise_ceil[:,i_sample] = np.nan
result = Result(model, evaluations, method=method,
cv_method='bootstrap_crossval', noise_ceiling=noise_ceil)
return result
