def tune(self, maxit=100): """ Automatic tuning of the discounting factors. The method will call the model tuner class to use the default parameters to tune the discounting factors and change the discount factor permenantly. User needs to refit the model after tuning. If user wants a more refined tuning and not change any property of the existing model, they should opt to use the @modelTuner class. """ simpleTuner = modelTuner() if self._printInfo: self.fitForwardFilter() print("The current mse is " + str(self.getMSE()) + '.') simpleTuner.tune(untunedDLM=self, maxit=maxit) self._setDiscounts(simpleTuner.getDiscounts(), change_component=True) if self._printInfo: self.fitForwardFilter() print("The new mse is " + str(self.getMSE()) + '.')
def setUp(self): self.mydlm = dlm(np.random.random(100)) + trend(2, discount=0.95) self.mytuner = modelTuner()