rsatoolbox.inference.crossvalsets module¶
generation of crossvalidation splits
- rsatoolbox.inference.crossvalsets.sets_k_fold(rdms, k_rdm=None, k_pattern=None, random=True, pattern_descriptor='index', rdm_descriptor='index')[source]¶
generates training and test set combinations by splitting into k similar sized groups. This version splits both over rdms and over patterns resulting in k_rdm * k_pattern (training, test) pairs.
If a k is set to 1 the corresponding dimension is not crossvalidated.
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
pattern_descriptor (String) – descriptor to select pattern groups
rdm_descriptor (String) – descriptor to select rdm groups
k_rdm (int) – number of rdm groups
k_pattern (int) – number of pattern groups
random (bool) – whether the assignment shall be randomized
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_k_fold_pattern(rdms, pattern_descriptor='index', k=None, random=False)[source]¶
generates training and test set combinations by splitting into k similar sized groups. This version splits in the given order or randomizes the order. For k=1 training and test_set are whole dataset, i.e. no crossvalidation is performed.
For only crossvalidating over patterns there is no independent training set for calculating a noise ceiling for the patterns. To express this we set ceil_set to None, which makes the crossvalidation function calculate a leave one rdm out noise ceiling for the right patterns instead.
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
pattern_descriptor (String) – descriptor to select groups
k (int) – number of groups
random (bool) – whether the assignment shall be randomized
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set = None
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_k_fold_rdm(rdms, k_rdm=None, random=True, rdm_descriptor='index')[source]¶
generates training and test set combinations by splitting into k similar sized groups. This version splits both over rdms and over patterns resulting in k_rdm * k_pattern (training, test) pairs.
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
rdm_descriptor (String) – descriptor to select rdm groups
k_rdm (int) – number of rdm groups
random (bool) – whether the assignment shall be randomized
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_leave_one_out_pattern(rdms, pattern_descriptor)[source]¶
generates training and test set combinations by leaving one level of pattern_descriptor out as a test set. This is only sensible if pattern_descriptor already defines larger groups!
the ceil_train_set contains the rdms for the test-patterns from the training-rdms. This is required for computing the noise-ceiling
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
pattern_descriptor (String) – descriptor to select groups
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_leave_one_out_rdm(rdms, rdm_descriptor='index')[source]¶
generates training and test set combinations by leaving one level of rdm_descriptor out as a test set. :param rdms: rdms to use :type rdms: rsatoolbox.rdm.RDMs :param rdm_descriptor: descriptor to select groups :type rdm_descriptor: String
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_of_k_pattern(rdms, pattern_descriptor=None, k=5, random=False)[source]¶
generates training and test set combinations by splitting into groups of k. This version splits in the given order or randomizes the order. If the number of patterns is not divisible by k patterns are added to the first groups such that those have k+1 patterns
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
pattern_descriptor (String) – descriptor to select groups
k (int) – number of groups
random (bool) – whether the assignment shall be randomized
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_of_k_rdm(rdms, rdm_descriptor='index', k=5, random=False)[source]¶
generates training and test set combinations by splitting into groups of k. This version splits in the given order or randomizes the order. If the number of patterns is not divisible by k patterns are added to the first groups such that those have k+1 patterns
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to use
pattern_descriptor (String) – descriptor to select groups
k (int) – number of groups
random (bool) – whether the assignment shall be randomized
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)
- rsatoolbox.inference.crossvalsets.sets_random(rdms, n_rdm=None, n_pattern=None, n_cv=2, pattern_descriptor='index', rdm_descriptor='index')[source]¶
generates training and test set combinations by selecting random test sets of n_rdm RDMs and n_pattern patterns and using the rest of the data as the training set.
If a n is set to 0 the corresponding dimension is not crossvalidated.
- Parameters
rdms (rsatoolbox.rdm.RDMs) – rdms to split
pattern_descriptor (String) – descriptor to select pattern groups
rdm_descriptor (String) – descriptor to select rdm groups
n_rdm (int) – number of rdms per test set
n_pattern (int) – number of patterns per test set
- Returns
list of tuples (rdms, pattern_idx) test_set(list): list of tuples (rdms, pattern_idx) ceil_set(list): list of tuples (rdms, pattern_idx)
- Return type
train_set(list)