Esempio n. 1
0
 def test_fit_univar_ts_with_covariates_for_local_models(self):
     naive = NaiveEnsembleModel(
         [NaiveDrift(),
          NaiveSeasonal(),
          Theta(),
          ExponentialSmoothing()])
     with self.assertRaises(ValueError):
         naive.fit(self.series1, self.series2)
Esempio n. 2
0
 def test_call_predict_global_models_multivariate_input_no_covariates(self):
     naive_ensemble = NaiveEnsembleModel([
         RNNModel(12, n_epochs=1),
         TCNModel(10, 2, n_epochs=1),
         NBEATSModel(10, 2, n_epochs=1),
     ])
     naive_ensemble.fit(self.seq1)
     naive_ensemble.predict(n=5, series=self.seq1)
Esempio n. 3
0
    def test_call_predict_global_models_univariate_input_no_covariates(self):
        naive_ensemble = NaiveEnsembleModel([
            RNNModel(12, n_epochs=1),
            TCNModel(10, 2, n_epochs=1),
            NBEATSModel(10, 2, n_epochs=1),
        ])
        with self.assertRaises(Exception):
            naive_ensemble.predict(5)

        naive_ensemble.fit(self.series1)
        naive_ensemble.predict(5)
Esempio n. 4
0
    def test_predict_ensemble_local_models(self):
        naive = NaiveSeasonal(K=5)
        theta = Theta()
        naive_ensemble = NaiveEnsembleModel([naive, theta])
        naive_ensemble.fit(self.series1 + self.series2)
        forecast_naive_ensemble = naive_ensemble.predict(5)
        naive.fit(self.series1 + self.series2)
        theta.fit(self.series1 + self.series2)
        forecast_mean = 0.5 * naive.predict(5) + 0.5 * theta.predict(5)

        self.assertTrue(
            np.array_equal(forecast_naive_ensemble.values(),
                           forecast_mean.values()))
Esempio n. 5
0
 def test_call_predict_global_models_multivariate_input_with_covariates(
         self):
     naive_ensemble = NaiveEnsembleModel([
         RNNModel(12, n_epochs=1),
         TCNModel(10, 2, n_epochs=1),
         NBEATSModel(10, 2, n_epochs=1),
     ])
     naive_ensemble.fit(self.seq1, self.cov1)
     predict_series = [s[:12] for s in self.seq1]
     predict_covariates = [c[:14] for c in self.cov1]
     naive_ensemble.predict(n=2,
                            series=predict_series,
                            past_covariates=predict_covariates)
Esempio n. 6
0
 def test_call_predict_local_models(self):
     naive_ensemble = NaiveEnsembleModel([NaiveSeasonal(), Theta()])
     with self.assertRaises(Exception):
         naive_ensemble.predict(5)
     naive_ensemble.fit(self.series1)
     naive_ensemble.predict(5)