Esempio n. 1
0
	def setUp(self):
		self.season_period = 2
		self.values = [np.array([[i+1], [i]]) for i in
							range(1, self.season_period * 2+1)]
		self.dataframe = DataFrame.from_items([('values', self.values)])
		self.hwi = HoltWintersI(self.dataframe,
		                        season_period=self.season_period)
		self.hwi._init_starting_arrays()
		self.coefs = [0.5] * 12
		self.A, self.B, self.G = flats_to_matrix(self.coefs)
Esempio n. 2
0
 def setUp(self):
     self.periods = 2
     self.values = [
         np.array([[i + 1], [i]]) for i in range(1, self.periods + 1)
     ]
     self.dataframe = DataFrame.from_items([('values', self.values)])
     self.model = HoltI(self.dataframe)
     self.coefs = [0.5] * 8
     self.A, self.B = flats_to_matrix(self.coefs)
     self.model._init_starting_arrays()
Esempio n. 3
0
    def _check_initial_coefs(self, coefs):
        """Set up initial coefficients
		:param coefs: list of coefs matrix [alpha, beta]
		:raises ValueError: if given coefs negative or greater that 1
		"""
        alpha, beta = flats_to_matrix(coefs)

        if any([
                alpha is not None and not isinstance(alpha, np.matrix),
                beta is not None and not isinstance(beta, np.matrix)
        ]):
            raise ValueError(u"Given coef matrix should be instance of "
                             u"np.matrix")

        if any([
                not self._is_correct_coefs_matrix(alpha),
                not self._is_correct_coefs_matrix(alpha)
        ]):
            raise ValueError(u"All given matrix coefs values should be in "
                             u"range [0;1]")
Esempio n. 4
0
 def _extract_coefs(self, coefs):
     """Overriden coefs retreive function found by optimization algorithm"""
     self.alpha, self.beta, self.gamma = self._coefs = flats_to_matrix(
         coefs)
Esempio n. 5
0
 def _extract_coefs(self, coefs):
     """Unpacks coefs array into separate coefs matrixes"""
     self.alpha, self.beta = self._coefs = flats_to_matrix(coefs)