flow-forecast icon indicating copy to clipboard operation
flow-forecast copied to clipboard

Time series classification example does not work properly

Open havocy28 opened this issue 1 year ago • 1 comments

I've been trying to use the library and find an example of a time series classifier that works. However, the only one I could find was on the confluence page here: https://flow-forecast.atlassian.net/wiki/spaces/FF/pages/1082163201/Training+Deep+Time+Series+Classification+Anomaly+Models

However, the linked kaggle notebook does not work. I receive the error:

interpolate should be below []

KeyError Traceback (most recent call last) in ----> 1 train_function("PyTorch", the_config)

/kaggle/working/flow-forecast/flood_forecast/trainer.py in train_function(model_type, params) 115 dataset_params["validation_path"], 116 dataset_params["test_path"], --> 117 params) 118 class2 = False if trained_model.params["dataset_params"]["class"] != "GeneralClassificationLoader" else True 119 takes_target = False

/kaggle/working/flow-forecast/flood_forecast/time_model.py in init(self, model_base, training_data, validation_data, test_data, params_dict) 110 params_dict: Dict): 111 self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') --> 112 super().init(model_base, training_data, validation_data, test_data, params_dict) 113 print("Torch is using " + str(self.device)) 114 if "weight_path_add" in params_dict:

/kaggle/working/flow-forecast/flood_forecast/time_model.py in init(self, model_base, training_data, validation_data, test_data, params) 37 self.model = self.load_model(model_base, params["model_params"]) 38 # params["dataset_params"]["forecast_test_len"] = params["inference_params"]["hours_to_forecast"] ---> 39 self.training = self.make_data_load(training_data, params["dataset_params"], "train") 40 self.validation = self.make_data_load(validation_data, params["dataset_params"], "valid") 41 self.test_data = self.make_data_load(test_data, params["dataset_params"], "test")

/kaggle/working/flow-forecast/flood_forecast/time_model.py in make_data_load(self, data_path, dataset_params, loader_type, the_class) 257 start_end_params = self.re_add_params(start_end_params, dataset_params, data_path) 258 start_end_params["sequence_length"] = dataset_params["sequence_length"] --> 259 loader = GeneralClassificationLoader(start_end_params, dataset_params["n_classes"]) 260 else: 261 # TODO support custom DataLoader

/kaggle/working/flow-forecast/flood_forecast/preprocessing/pytorch_loaders.py in init(self, params, n_classes) 397 # Remove sequence_length prior to calling the super class 398 params.pop("sequence_length") --> 399 super().init(**params) 400 401 def getitem(self, idx: int):

/kaggle/working/flow-forecast/flood_forecast/preprocessing/pytorch_loaders.py in init(self, file_path, forecast_history, forecast_length, target_col, relevant_cols, scaling, start_stamp, end_stamp, gcp_service_key, interpolate_param, sort_column, scaled_cols, feature_params, no_scale) 68 if interpolate: 69 df = interpolate_dict[interpolate["method"]](df, **interpolate["params"]) ---> 70 self.df = df[relevant_cols + relevant_cols3].copy() 71 print("Now loading " + file_path) 72 self.original_df = df

/opt/conda/lib/python3.7/site-packages/pandas/core/frame.py in getitem(self, key) 3028 if is_iterator(key): 3029 key = list(key) -> 3030 indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1] 3031 3032 # take() does not accept boolean indexers

/opt/conda/lib/python3.7/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis, raise_missing) 1264 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr) 1265 -> 1266 self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing) 1267 return keyarr, indexer 1268

/opt/conda/lib/python3.7/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing) 1314 if raise_missing: 1315 not_found = list(set(key) - set(ax)) -> 1316 raise KeyError(f"{not_found} not in index") 1317 1318 not_found = key[missing_mask]

KeyError: "['labels'] not in index"

Any advice on how to fix this or example notebooks that demo the ability for time series classifications that work properly?

havocy28 avatar Jul 20 '22 22:07 havocy28

Where were you running it from? Did you fork the notebook on Kaggle?

isaacmg avatar Jul 22 '22 04:07 isaacmg

Closing due to lack of activity.

isaacmg avatar Aug 15 '22 22:08 isaacmg