Kfold
Description
This module contains the method kfold, which is used to perform a stratified k-fold cross-validation. The method is designed to work with eegdata dictionary.
- bciflow.modules.core.kfold.find_key_with_value(dictionary, i)[source]
This function returns the key of a dictionary given a value.
- Parameters:
dictionary (dict) – The dictionary to be searched.
i (any) – The value to be searched for.
- Returns:
key – The key of the dictionary that contains the value i. If the value is not found, returns None.
- Return type:
any
- bciflow.modules.core.kfold.kfold(target, start_window=0, start_test_window=None, window_size=2, pre_folding={}, pos_folding={})[source]
This method is used to perform a stratified k-fold cross-validation. The method is designed to work with eegdata dictionary.
- Parameters:
target (dict) – Input EEG data.
start_window (int)
start_test_window (int)
pre_folding (dict) – A dictionary containing the preprocessing functions to be applied to the data before the cross-validation. The keys are the names of the preprocessing functions, and the values are tuples containing the function and its parameters.
pos_folding (dict) – A dictionary containing the postprocessing functions to be applied to the data before the cross-validation. The keys are the names of the postprocessing functions, and the values are the functions.
window_size (float) – The size of the window to be used in the crop method of eegdata.
source (list) – List of Eeg data from anothers subjects to be used as a source for the Transfer Learning modules
- Returns:
results – A pandas dataframe containing the results of the cross-validation. The columns are ‘fold’, ‘tmin’, ‘true_label’, and the labels of the events in the target object.
- Return type:
pandas.DataFrame