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.txt
if it is present else creates a feature names automatically.- Return type
dict
- Return data_dict
A dictionary of Python list, which contains
number_of_features
andname_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
samples
andlabels
(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_labels
andsplit_percentage
.