Closed parimuns closed 4 years ago
I am trying to model NPTS using Gluonts. Please guide me on how to get the probabilistic forecasting results using NPTSEstimator.
'from gluonts.model.npts import NPTSEstimator from gluonts.trainer import Trainer from gluonts.model.npts import NPTSPredictor Predictor1=NPTSPredictor(freq='H', prediction_length=24, context_length= 48, kernel_type='exponential',use_seasonal_model= True, use_default_time_features = True) predictor=Predictor1.predict(dataset=train_ds,num_samples=100) test_ds = ListDataset([{FieldName.TARGET: target, FieldName.START: start, FieldName.FEAT_DYNAMIC_REAL: [fdr], } for (target, start,fdr) in zip(target, start, feat_dynamic_real, )], freq=freq) from gluonts.evaluation.backtest import make_evaluation_predictions forecast_it, ts_it = make_evaluation_predictions( dataset=test_ds, # test dataset predictor=predictor, # predictor num_samples=100, # number of sample paths we want for evaluation )
I get error
AttributeError Traceback (most recent call last) <ipython-input-25-c98cb60cf47a> in <module> 3 dataset=test_ds, # test dataset 4 predictor=predictor, # predictor ----> 5 num_samples=100, # number of sample paths we want for evaluation 6 ) c:\users\appdata\local\programs\python\python37\lib\site-packages\gluonts\evaluation\backtest.py in make_evaluation_predictions(dataset, predictor, num_samples) 60 """ 61 ---> 62 prediction_length = predictor.prediction_length 63 freq = predictor.freq 64 AttributeError: 'generator' object has no attribute 'prediction_length'
You set predictor to Predictor1.predict(...). predict() returns an iterator over the predictions.
predictor
Predictor1.predict(...)
predict()
I think what you want is to pass Predictor1 to make_evaluation_predictions instead.
Predictor1
make_evaluation_predictions
Got it.Thanks
I am trying to model NPTS using Gluonts. Please guide me on how to get the probabilistic forecasting results using NPTSEstimator.
I get error