## Use TSFRESH-library to forecast values

4

1

Have some issue with understanding how to use TSFERSH-library (version 0.4.0) to forecast next N-values of particular series. Below my code:

    # load data train/test datasets
train, Y, test, YY = prepare_train_test()
train['TS_ID'] = pd.Categorical(train['QTR_HR_START']).codes
test['TS_ID'] = pd.Categorical(test['QTR_HR_START']).codes
# add ordered id for concrete event of series
for id in sorted(train['TS_ID'].unique()):
train.ix[train.TS_ID == id, 'TIME_ORDER_ID'] =  pd.Categorical(train[train.TS_ID == id]['DATETIME']).codes
for id in sorted(test['TS_ID'].unique()):
test.ix[test.TS_ID == id, 'TIME_ORDER_ID'] = pd.Categorical(test[test.TS_ID == id]['DATETIME']).codes
# perform feature extraction for my signal
extraction_settings = FeatureExtractionSettings()
extraction_settings.IMPUTE = impute  # Fill in Infs and NaNs
X = extract_features(train, column_id='TS_ID', feature_extraction_settings=extraction_settings).values
XT = extract_features(test, column_id='TS_ID', feature_extraction_settings=extraction_settings).values

# there should be as example
# model = xgb.DMatrix(X, label=Y, missing=np.nan)
# model.fit()
# model.predict(XT)


However, after line X = extract_features(...) I see at debugger following results

It's mean that initial X-dataset/features (shape=(722,10) were transformed to shape (80, 1899).

Where does '80' come from? I guess from train.TS_ID comes. But my XT-dataset still contains 722-rows (9 days * 80 different series per day).

So, how can I predict for 9 days in advance? or is there only forecast for next period?

Which version of tsfresh are you using? – MaxBenChrist – 2016-12-25T23:12:23.370

The latest one - 0.4 – SpanishBoy – 2016-12-26T10:28:56.637

From tsfresh, you get a feature matrix with one row for each time series id. You will then have to shift your feature matrix and train the regressor to forecast the time series – MaxBenChrist – 2016-12-27T21:43:02.330

tsfresh itself does not contain any estimator. You have to use sklearn, tensorflow or something similar for that. – MaxBenChrist – 2016-12-27T21:43:48.430

@MaxBenChrist - could you elaborate on what is meant by "shift the feature matrix and train the regressor to forecast the time series" ? I currently have a feature matrix but not sure how to convert this into predictive modelling. – joel.wilson – 2018-08-28T12:23:22.137