示例#1
0
    def test_untrained_models(self):
        model = NaiveDrift()
        _ = NaiveEnsembleModel([model])

        # trained models should raise error
        model.fit(self.series1)
        with self.assertRaises(ValueError):
            NaiveEnsembleModel([model])
示例#2
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)
示例#3
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()))
示例#4
0
 def test_input_models_local_models(self):
     with self.assertRaises(ValueError):
         NaiveEnsembleModel([])
     with self.assertRaises(ValueError):
         NaiveEnsembleModel(
             [NaiveDrift, NaiveSeasonal, Theta, ExponentialSmoothing])
     with self.assertRaises(ValueError):
         NaiveEnsembleModel(
             [NaiveDrift(), NaiveSeasonal,
              Theta(),
              ExponentialSmoothing()])
     NaiveEnsembleModel(
         [NaiveDrift(),
          NaiveSeasonal(),
          Theta(),
          ExponentialSmoothing()])
示例#5
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)
示例#6
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)
示例#7
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)
示例#8
0
 def test_input_models_global_models(self):
     NaiveEnsembleModel([RNNModel(12), TCNModel(10, 2), NBEATSModel(10, 2)])
示例#9
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)
示例#10
0
 def test_input_models_mixed(self):
     with self.assertRaises(ValueError):
         NaiveEnsembleModel([NaiveDrift(), Theta(), RNNModel(12)])