4
$\begingroup$

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()
    # add series ID         
    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 enter image description here

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?

$\endgroup$
  • $\begingroup$ Which version of tsfresh are you using? $\endgroup$ – MaxBenChrist Dec 25 '16 at 23:12
  • $\begingroup$ The latest one - 0.4 $\endgroup$ – SpanishBoy Dec 26 '16 at 10:28
  • $\begingroup$ 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 $\endgroup$ – MaxBenChrist Dec 27 '16 at 21:43
  • $\begingroup$ tsfresh itself does not contain any estimator. You have to use sklearn, tensorflow or something similar for that. $\endgroup$ – MaxBenChrist Dec 27 '16 at 21:43
  • $\begingroup$ @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. $\endgroup$ – joel.wilson Aug 28 '18 at 12:23
1
$\begingroup$

TSFRESH is already supporting Time Series Forecast.

See details and example here and here

| improve this answer | |
$\endgroup$
  • $\begingroup$ I have the same question and not able to understand how to use the tsfresh on predictive modelling. The example on the google stock has "id" column which I do not have. I get is a 5 * 784 matrix(due to 5 features) and completly lost the time factor from the output data. How to leverage the time series facility? Any example? $\endgroup$ – joel.wilson Aug 28 '18 at 12:27
  • $\begingroup$ Yes, I had an example ... If you can post more exactly the input-structure, I will try to adapt the example $\endgroup$ – SpanishBoy Sep 10 '18 at 13:45
  • $\begingroup$ I got this problem aswell, the notebook seems not to be up to date anymore. Does anyone have a tsfresh solution which works? $\endgroup$ – iLuvCode May 14 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.