Loads dataset from csv files contained in `root_path` into a dataframe, optionally choosing from `pattern` Args: root_path: directory containing all individual .csv files file_list: optionally, provide a list of file paths within `root_path` to consider.
(self, root_path, file_list=None, flag=None)
| 634 | print(len(self.all_IDs)) |
| 635 | |
| 636 | def load_all(self, root_path, file_list=None, flag=None): |
| 637 | """ |
| 638 | Loads dataset from csv files contained in `root_path` into a dataframe, optionally choosing from `pattern` |
| 639 | Args: |
| 640 | root_path: directory containing all individual .csv files |
| 641 | file_list: optionally, provide a list of file paths within `root_path` to consider. |
| 642 | Otherwise, entire `root_path` contents will be used. |
| 643 | Returns: |
| 644 | all_df: a single (possibly concatenated) dataframe with all data corresponding to specified files |
| 645 | labels_df: dataframe containing label(s) for each sample |
| 646 | """ |
| 647 | # Select paths for training and evaluation |
| 648 | if file_list is None: |
| 649 | data_paths = glob.glob(os.path.join(root_path, '*')) # list of all paths |
| 650 | else: |
| 651 | data_paths = [os.path.join(root_path, p) for p in file_list] |
| 652 | if len(data_paths) == 0: |
| 653 | raise Exception('No files found using: {}'.format(os.path.join(root_path, '*'))) |
| 654 | if flag is not None: |
| 655 | data_paths = list(filter(lambda x: re.search(flag, x), data_paths)) |
| 656 | input_paths = [p for p in data_paths if os.path.isfile(p) and p.endswith('.ts')] |
| 657 | if len(input_paths) == 0: |
| 658 | pattern='*.ts' |
| 659 | raise Exception("No .ts files found using pattern: '{}'".format(pattern)) |
| 660 | |
| 661 | all_df, labels_df = self.load_single(input_paths[0]) # a single file contains dataset |
| 662 | |
| 663 | return all_df, labels_df |
| 664 | |
| 665 | def load_single(self, filepath): |
| 666 | df, labels = load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True, |