check_split

selfeeg.dataloading.load.check_split(EEGlen: DataFrame, EEGsplit: DataFrame, Labels=None, return_ratio=False, verbose=True) dict | None[source]

check_split calculate and print split ratios to check if the split has been performed correctly.

Parameters:
  • EEGlen (pd.DataFrame) – The output of the get_eeg_partition_number function.

  • EEGsplit (pd.DataFrame) – The output of the get_eeg_split_table function. If you have used the get_eeg_split_table_kfold function, make sure to get a specific split by calling the get_split function.

  • Labels (ArrayLike, optional) –

    A list or 1d array like objects with the label of each file listed in the partition table. It is the same object given to the called split function.

    Default = None

  • return_ratio (bool, otional) –

    Whether to return the calculated ratio in a dictionary or simply print them.

    Default = False

  • verbose (bool, optional) –

    Wheter to generate a summary print of the calculated ratios or not.

    Default = True

Returns:

ratios (dict, optional) – A dictionary with the calculated ratios. If labels were given, a numpy array

Example

>>> import pickle
>>> import selfeeg.dataloading as dl
>>> import selfeeg.utils
>>> labels = utils.create_dataset()
>>> def loadEEG(path):
...     with open(path, 'rb') as handle:
...         EEG = pickle.load(handle)
...     x = EEG['data']
...     return x
>>>  EEGlen = dl.get_eeg_partition_number('Simulated_EEG',freq=128, window=2,
...                                    overlap=0.3, load_function=loadEEG )
>>>  EEGsplit = dl.get_eeg_split_table(EEGlen) #default 60/20/20 ratio
>>>  ratios = dl.check_split(EEGlen, EEGsplit, return_ratio=True) # 0.6/0.2/0.2
>>>  print(ratios['train_ratio'], ratios['val_ratio'], ratios['test_ratio'])