I’m using GluonTS to make time series predictions with the TransformerPredictor. However, when I try to convert the forecast_it iterator to a list, I encounter the following error:
Setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (15, 11) + inhomogeneous part. During handling of the above exception, another exception occurred: source array must be array like object
train_data = ListDataset(
[{
'start': df.index[0],
'target': df['target'].values,
'feat_dynamic_real': df['feat_dynamic_real'].values.T,
'feat_static_cat': df['feat_static_cat'].values if 'feat_static_cat' in df.columns else None
}],
freq='D'
)
predictor = TransformerPredictor(
input_size=1,
prediction_length=30,
freq='D',
context_length=30,
trainer=Trainer(epochs=10)
)
predictor.train(train_data)
forecast_it, ts_it = make_evaluation_predictions(dataset=train_data, predictor=predictor)
forecasts = list(forecast_it) # This line raises the error
Tried ensuring all the time series are of equal lengths. Did not resolve the issue.
Grace Xu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.