I have the following loop creating kpi values for each of my 5 subsets.
list = [sku_1,sku_2,sku_3,sku_4,sku_5]
for i in list:
df = triple_exp_smooth_mul(i, slen=12, extra_periods=4, alpha=0.3,beta=0.2, phi=0.9, gamma=0.2)
kpi(df)
print(kpi)
Output:
Bias: 3.19, 1.06%
MAPE: 14.93%
MAE: 43.94, 14.64%
RMSE: 56.84, 18.94%
<function kpi at 0x000002634941C8B0>
Bias: -2.57, -1.31%
MAPE: 15.27%
MAE: 28.04, 14.27%
RMSE: 40.29, 20.50%
<function kpi at 0x000002634941C8B0>
Bias: -7.93, -3.77%
MAPE: 16.98%
MAE: 33.76, 16.08%
RMSE: 48.83, 23.25%
<function kpi at 0x000002634941C8B0>
Bias: -15.05, -2.98%
MAPE: 37.16%
MAE: 170.31, 33.75%
RMSE: 224.58, 44.50%
<function kpi at 0x000002634941C8B0>
Bias: 5.37, 2.03%
MAPE: 21.45%
MAE: 53.89, 20.41%
RMSE: 78.66, 29.79%
<function kpi at 0x000002634941C8B0>
Is there a way to store this in a nice table, something like this:
KPI | SKU1 Value | SKU1 Scaled |
---|---|---|
BIAS | xx | % |
MAPE | xx | % |
MAE | xx | % |
RMSE | xx | % |
With the SKU Value and SKU scaled in the columns?
Edit: Code used to create KPI function:
#Defining the function for measuring the forecast accuracy for each Forecast "#Credits to Nicolas Candeput "Data Science For Supply Chain Forecasting""
def kpi(df):
dem_ave = df.loc[df['Error'].notnull(),'Demand'].mean()
bias_abs = df['Error'].mean()
bias_rel = bias_abs / dem_ave
print('Bias: {:0.2f}, {:.2%}'.format(bias_abs,bias_rel))
MAPE = (df['Error'].abs()/df['Demand']).mean()
print('MAPE: {:.2%}'.format(MAPE))
MAE_abs = df['Error'].abs().mean()
MAE_rel = MAE_abs / dem_ave
print('MAE: {:0.2f}, {:.2%}'.format(MAE_abs,MAE_rel))
RMSE_abs = np.sqrt((df['Error']**2).mean())
RMSE_rel = RMSE_abs / dem_ave
print('RMSE: {:0.2f}, {:.2%}'.format(RMSE_abs,RMSE_rel))