autokeras
autokeras copied to clipboard
Bug: TimeseriesForecaster predicting fails on KeyError
Bug Description
TimeseriesForecaster predicting fails:
Traceback (most recent call last):
File "../ak.py", line 156, in
Bug Reproduction
Code for reproducing the bug: clf = ak.TimeseriesForecaster( lookback=lookback, predict_until=rebalance_freq, metrics=metrics_fns, objective=kt.Objective(f"val_{metrics[0]}", direction="max"), directory=models_path )
clf.fit( x=data_x_train, y=data_y_train, validation_data=(data_x_val, data_y_val), batch_size=BATCH_SIZE )
with keras.utils.custom_object_scope(helper.objectives): pred_data = data_x_test.loc[data_x_test.index.get_level_values(level=0) < end_train] predictions = clf.predict(pred_data)
Data used by the code: pred_data: columns: Date,,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97 rows: 1992-12-28,AAPL, 1992-12-28,FB, .. elements: floats
Expected Behavior
Predicting future predict_until data points.
Setup Details
Include the details about the versions of:
- OS type and version: Ubuntu 20.04.4 LTS (Focal Fossa)
- Python: 3.8.10
- autokeras: 1.0.19
- keras-tuner: 1.1.2
- scikit-learn: 1.1.1
- numpy: 1.23.0
- pandas: 1.4.3
- tensorflow: 2.9.1
Additional context
Workaround in autokeras/autokeras/preprocessors/common.py - change line 112: try: column_type = self.column_types[column_name] except KeyError as ke: print(f"KeyError: {ke}, using string key..") column_type = self.column_types[str(column_name)]