Utility¶
The utility.py can do the following:
Reading CSV files¶
- class spikes.utility.ReadCSV(path, log=False)[source]¶
Reads the CSV files in a given folder.
If no folder names is give, this program searches for folder
Data; If no location is given.- Parameters:
path (str) – Needed. Location of the directory containing the data files.
log (bool) – Default False. Verbose mode.
- get_feature_names()[source]¶
Reads feature names from
feature_names_eeg.txtif it is present else creates a feature names automatically.- Return type:
dict
- Return data_dict:
A dictionary of Python list, which contains
number_of_featuresandname_features.
- get_samples()[source]¶
Reads all the sample starting with sam*.csv and returns a Pandas DataFrame.
- Return type:
dict
- Return samples:
A dictionary of
samplesandlabels(this depends if you have labels file).
>>> data = ReadCSV('Data') >>> data.get_samples() { 'labels': [...], 'samples: array(...) }
- get_split_data(split_to=0.5)[source]¶
Split samples into training and testing data.
The default test size is 0.5 (50%)
- Parameters:
split_to (float) – Percentage split training and testing. Defaults to
0.5.- Return type:
dict
- Returns:
Dictionary of
train_samples,train_labels,test_samples,test_labelsandsplit_percentage.
Helpers¶
Reads the data from folders and json files.