From 55db5709a9678d87724ab0e85105e6d745be26a4 Mon Sep 17 00:00:00 2001 From: nuluh Date: Mon, 19 Aug 2024 13:20:14 +0700 Subject: [PATCH] refactor(script): Add time-domain feature extraction functionality called `ExtractTimeFeatures` function returning features in {dictionary} that later called in `build_features.py`. This function will be called for each individual .`csv`. Each returning value later appended in `build_features.py`. This function approach rather than just assigning class ensure the flexibility and enhance maintainability. --- code/src/features/time_domain_features.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/src/features/time_domain_features.py b/code/src/features/time_domain_features.py index d64566c..d37b061 100644 --- a/code/src/features/time_domain_features.py +++ b/code/src/features/time_domain_features.py @@ -36,6 +36,13 @@ class FeatureExtractor: result += f"{feature}: {value:.4f}\n" return result +def ExtractTimeFeatures(object): + data = pd.read_csv(object, skiprows=1) + extractor = FeatureExtractor(data.iloc[:, 1].values) # Assuming the data is in the second column + features = extractor.features + return features + # Save features to a file + # np.savez(output_file, **features) # Usage # Assume you have a CSV file with numerical data in the first column # Create an instance of the class and pass the path to your CSV file