in prediction_postprocessing_scripts/dynamic_time_warping_analysis.py [0:0]
def load_time_series(input_folder, signature_ids_to_consider=None):
"""Recursively loads all available time series from the input folder and subfolders, filtering by provided signature IDs."""
time_series_dict = {}
for root, _, files in os.walk(input_folder):
for filename in files:
if filename.endswith("_timeseries_data.csv"):
sig_id = int(filename.split("_")[0])
# Only load the file if its signature ID is in the provided list, or if no filter is applied
if signature_ids_to_consider is not None and sig_id not in signature_ids_to_consider:
continue
df = pd.read_csv(os.path.join(root, filename))
if "push_timestamp" in df.columns and "value" in df.columns:
df = df.sort_values(by="push_timestamp")
time_series_dict[sig_id] = df["value"].dropna().values
return time_series_dict