# plt.figure(figsize=(10,6)) # plt.plot(data_final.date,data_final.sales) # plt.plot(data_final.date,data_final.forecast) # plt.savefig("/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/plots/"+ str(ref) + '.png') #writing the result in a csv #TODO: si forecast est negative => rendre la valeur = 0 data_final.forecast[data_final.forecast < 0] = 0 # delete hh:mm:ss part from the date data_final['date'] = data_final['date'].astype("str").str.split(' ').str[0] #using the interpretability model data = data_final.copy() data = data[['date', 'PV', 'forecast']].dropna() list_dicts = [] kpi_sku = {"indicators": "values"} kpi_sku.update(evaluate_all(data.PV.values, data.forecast.values)) list_dicts.append(kpi_sku) #create the dataframe of the kpi for each sku from the dict created kpi_df = pd.DataFrame(list_dicts, columns=list_dicts[0].keys()) kpi_df[['mse', 'mape', 'smape', 'mae', 'mda']] data_final['mape'] = kpi_df.mape SCHEMA_PREV = [{ "description": "date", "mode": "REQUIRED", "name": "date", "type": "STRING" }, { "description": "nombre de pagevues reel", "mode": "NULLABLE",
slack_message = {'text': 'saving forecasts in csv ! :)'} requests.post(url=web_hook_url, data=json.dumps(slack_message)) #using the interpretability model data = pd.read_csv( "/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/tables/" + "RES_FINAL" + ".csv") #using only the test set part data = data[['date', 'sales', 'forecast', 'sku']].dropna() DAP = diag_ability_performance(data.sales.values, data.forecast.values, data.date.values, data.sku.values) DAP.to_csv( "/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/tables/" + "ROC" + ".csv", sep=";", index=False) #this csv is used in a powerbi dashboard to visualize which sku have better performed and which ones created created a huge gap list_dicts = [] for sku in np.unique(data.sku): data_sku = data[data.sku == sku] kpi_sku = {"sku": sku} kpi_sku.update( evaluate_all(data_sku.sales.values, data_sku.forecast.values)) list_dicts.append(kpi_sku) #create the dataframe of the kpi for each sku from the dict created kpi_df = pd.DataFrame(list_dicts, columns=list_dicts[0].keys()) kpi_df.to_csv( "/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/tables/" + "kpi_df" + ".csv", sep=";", index=False)
#TODO : ameliorer le plot : ajouter 3 couleur (train, test ,futur) # plt.figure(figsize=(10,6)) # plt.plot(data_final.date,data_final.sales) # plt.plot(data_final.date,data_final.forecast) # plt.savefig("/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/plots/"+ str(ref) + '.png') #writing the result in a csv #TODO: si forecast est negative => rendre la valeur = 0 data_final.forecast[ data_final.forecast < 0 ] = 0 data_final['date'] = data_final['date'].astype("str").str.split(' ').str[0] #using the interpretability model data = data_final.copy() data = data[['date', 'max_nb_comm_hour', 'forecast']].dropna() list_dicts = [] kpi_sku = {"indicators" : "values"} kpi_sku.update(evaluate_all(data.max_nb_comm_hour.values,data.forecast.values)) list_dicts.append(kpi_sku) #create the dataframe of the kpi for each sku from the dict created kpi_df = pd.DataFrame(list_dicts,columns = list_dicts[0].keys()) kpi_df[['mse','mape','smape','mae','mda']] data_final['mape'] = kpi_df.mape data_final.assign(mape='kpi_df.mape') SCHEMA_PREV = [ { "description": "date", "mode": "REQUIRED", "name": "date", "type": "STRING" },
#TODO : ameliorer le plot : ajouter 3 couleur (train, test ,futur) # plt.figure(figsize=(10,6)) # plt.plot(data_final.date,data_final.sales) # plt.plot(data_final.date,data_final.forecast) # plt.savefig("/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/plots/"+ str(ref) + '.png') #writing the result in a csv #TODO: si forecast est negative => rendre la valeur = 0 data_final.forecast[data_final.forecast < 0] = 0 data_final['date'] = data_final['date'].astype("str").str.split(' ').str[0] #using the interpretability model data = data_final.copy() data = data[['date', 'nb_ajout_panier', 'forecast']].dropna() list_dicts = [] kpi_sku = {"indicators": "values"} kpi_sku.update(evaluate_all(data.nb_ajout_panier.values, data.forecast.values)) list_dicts.append(kpi_sku) #create the dataframe of the kpi for each sku from the dict created kpi_df = pd.DataFrame(list_dicts, columns=list_dicts[0].keys()) kpi_df[['mse', 'mape', 'smape', 'mae', 'mda']] data_final['mape'] = kpi_df.mape SCHEMA_PREV = [{ "description": "date", "mode": "REQUIRED", "name": "date", "type": "STRING" }, { "description": "nombre de pagevues reel", "mode": "NULLABLE",
#TODO : ameliorer le plot : ajouter 3 couleur (train, test ,futur) # plt.figure(figsize=(10,6)) # plt.plot(data_final.date,data_final.sales) # plt.plot(data_final.date,data_final.forecast) # plt.savefig("/home/alaeddinez/MyProjects/LMFR-BigData--supply--Previsions/output/plots/"+ str(ref) + '.png') #writing the result in a csv #TODO: si forecast est negative => rendre la valeur = 0 data_final.forecast[data_final.forecast < 0] = 0 data_final['date'] = data_final['date'].astype("str").str.split(' ').str[0] #using the interpretability model data = data_final.copy() data = data[['date', 'nb_comm', 'forecast']].dropna() list_dicts = [] kpi_sku = {"indicators": "values"} kpi_sku.update(evaluate_all(data.nb_comm.values, data.forecast.values)) list_dicts.append(kpi_sku) #create the dataframe of the kpi for each sku from the dict created kpi_df = pd.DataFrame(list_dicts, columns=list_dicts[0].keys()) kpi_df[['mse', 'mape', 'smape', 'mae', 'mda']] data_final['mape'] = kpi_df.mape data_final.assign(mape='kpi_df.mape') SCHEMA_PREV = [{ "description": "date", "mode": "REQUIRED", "name": "date", "type": "STRING" }, { "description": "nombre reel",