def test_simple_exponential_smoothing_key(self): ses = simple_exponential_smoothing_forecast(demand=self._orders, alpha=0.5, forecast_length=6, initial_period=18) for k in ses: self.assertIn(k, self.ses_components)
def createSupplyChainAnalysis(pdesc): raw_df = createPdForAnalysis() orders_df = raw_df analyse_kv = dict(df=raw_df, start=1, interval_length=12, interval_type='months', z_value=Decimal(1.28), reorder_cost=Decimal(400), retail_price=Decimal(455), file_type='csv', currency='USD') print(raw_df) analysis_df = analyse(**analyse_kv) analysis_rev = analysis_df[['sku', 'revenue']] row_ds = raw_df[raw_df['Sku'] == pdesc].squeeze() ses = simple_exponential_smoothing_forecast(demand=list(row_ds[1:12]), alpha=0.5, forecast_length=6, initial_period=18) forecast_breakdown_df = pd.DataFrame( ses.get('forecast_breakdown', 'UNKNOWN')) regression = { 'regression': [(ses.get('statistics')['slope'] * i) + ses.get('statistics')['intercept'] for i in range(1, 12)] } print(regression) forecast_breakdown_df['regression'] = regression.get('regression') forecast_breakdown_df.plot(x='t', y=['one_step_forecast', 'demand', 'regression']) plt.show()
def _generate_optimised_ses_forecast(self): try: demand = (list(self.__orders.get("demand"))) orders = [int(i) for i in demand] # filter for lowest standard order and use for evo model ses_evo_forecast = simple_exponential_smoothing_forecast(demand=orders, smoothing_level_constant=0.5, optimise=True) return ses_evo_forecast except TypeError as e: print('Exponential smoothing forecast (evolutionary model) failed. {}'.format(e))
def _generate_optimised_ses_forecast(self): try: demand = (list(self.__orders.get("demand"))) orders = [int(i) for i in demand] ses_evo_forecast = simple_exponential_smoothing_forecast( demand=orders, smoothing_level_constant=0.5) return ses_evo_forecast except TypeError as e: print( 'Exponential smoothing forecast (evolutionary model) failed. {}' .format(e)) except OSError as e: print(e)