Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -160,14 +160,6 @@ ax.grid()
|
|
160 |
# ax.show()
|
161 |
st.pyplot(fig)
|
162 |
|
163 |
-
# данные по среднему чеку также спрогнозируем помесячно
|
164 |
-
# Обучаем модель SARIMA
|
165 |
-
# seasonal_order = (1, 1, 1, 12) # Настройте параметры сезонности (P, D, Q, s)
|
166 |
-
# model = SARIMAX(data['Средний чек'].dropna(), seasonal_order=seasonal_order)
|
167 |
-
# model_fit = model.fit()
|
168 |
-
# # Прогнозируем
|
169 |
-
# forecast_chek = model_fit.forecast(steps=count_month)
|
170 |
-
|
171 |
forecast_chek = fit_model(data['Средний чек'], count_month)
|
172 |
|
173 |
# Визуализируем результаты
|
@@ -180,11 +172,11 @@ ax.legend()
|
|
180 |
ax.grid()
|
181 |
st.pyplot(fig)
|
182 |
|
183 |
-
st.subheader('Прогнозные значения без влияния фичи')
|
184 |
df_no_feature = pd.DataFrame()
|
185 |
df_no_feature['Дата'] = forecast_new.index
|
186 |
-
df_no_feature['Оборот'] = list(forecast_new)
|
187 |
-
df_no_feature['Средний чек'] = list(forecast_chek)
|
188 |
st.dataframe(df_no_feature)
|
189 |
|
190 |
list_retention = [0.48, 0.58, 0.52, 0.47, 0.44, 0.42, 0.4, 0.38, 0.37, 0.35, 0.34, 0.33, 0.32, 0.31, 0.30, 0.29, 0.28, 0.27, 0.26, 0.25, 0.24]
|
@@ -196,7 +188,7 @@ month_start = date_start
|
|
196 |
# summ_from_feature = 0
|
197 |
|
198 |
# random_colors = ['red', 'blue', 'lightgreen', 'gold', 'slategreay', 'indigo', 'coral', 'plum', 'blue', 'tomato']
|
199 |
-
new_summ_with_features = ['red']
|
200 |
|
201 |
if money == 'Выставлю сам':
|
202 |
forecast_chek = [money_self for i in range(len(forecast_new))]
|
@@ -206,7 +198,7 @@ if money == 'Выставлю сам':
|
|
206 |
|
207 |
list_with_colour = ['red', 'blue', 'lightgreen', 'gold', 'plum', 'indigo', 'coral', 'plum', 'blue', 'tomato']
|
208 |
r = 1
|
209 |
-
oborot = df_no_feature['Оборот']
|
210 |
|
211 |
for j in list_with_data_by_features:
|
212 |
# st.write(j)
|
@@ -214,6 +206,7 @@ for j in list_with_data_by_features:
|
|
214 |
forecast_chek = [j[3] for l in range(len(forecast_new))]
|
215 |
new_summ_with_features = []
|
216 |
list_retention = list_retention[:duration+1] + [0 for g in range(25)]
|
|
|
217 |
for i in range(len(forecast_new)):
|
218 |
# st.write(i)
|
219 |
summ_from_feature = 0
|
@@ -224,7 +217,7 @@ for j in list_with_data_by_features:
|
|
224 |
# st.write((forecast_new.index[i].date() >= j[5]) & (
|
225 |
# forecast_new.index[i].date() <= j[5] + timedelta(days=180)))
|
226 |
# oborot = df_no_feature['Оборот']
|
227 |
-
summ_from_feature
|
228 |
# print("Доп сумма от фичи:", summ_from_feature)
|
229 |
# st.write(summ_from_feature)
|
230 |
|
@@ -246,7 +239,7 @@ for j in list_with_data_by_features:
|
|
246 |
fig, ax = plt.subplots(figsize=(10, 5))
|
247 |
# plt.plot(train['Оборот по всем копилкам за месяц'], label='Train')
|
248 |
ax.plot(data['Оборот'], label='Исторические данные', color='orange')
|
249 |
-
ax.plot(forecast_new.index,
|
250 |
for k in range(len(list_with_data_by_features)):
|
251 |
ax.plot(forecast_new.index, df_no_feature[f'Прогноз с учетом фичи # {k+1}'], label=f'Прогноз с добавлением фичи # {k+1}', color=list_with_colour[k], linestyle='--')
|
252 |
|
|
|
160 |
# ax.show()
|
161 |
st.pyplot(fig)
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
forecast_chek = fit_model(data['Средний чек'], count_month)
|
164 |
|
165 |
# Визуализируем результаты
|
|
|
172 |
ax.grid()
|
173 |
st.pyplot(fig)
|
174 |
|
175 |
+
st.subheader('Прогнозные значения без влияния фичи с поправочным коэффициентом 0,5')
|
176 |
df_no_feature = pd.DataFrame()
|
177 |
df_no_feature['Дата'] = forecast_new.index
|
178 |
+
df_no_feature['Оборот поогноз'] = [i*0.95 for i in list(forecast_new)]
|
179 |
+
df_no_feature['Средний чек'] = [i*0.95 for i in list(forecast_chek)]
|
180 |
st.dataframe(df_no_feature)
|
181 |
|
182 |
list_retention = [0.48, 0.58, 0.52, 0.47, 0.44, 0.42, 0.4, 0.38, 0.37, 0.35, 0.34, 0.33, 0.32, 0.31, 0.30, 0.29, 0.28, 0.27, 0.26, 0.25, 0.24]
|
|
|
188 |
# summ_from_feature = 0
|
189 |
|
190 |
# random_colors = ['red', 'blue', 'lightgreen', 'gold', 'slategreay', 'indigo', 'coral', 'plum', 'blue', 'tomato']
|
191 |
+
# new_summ_with_features = ['red']
|
192 |
|
193 |
if money == 'Выставлю сам':
|
194 |
forecast_chek = [money_self for i in range(len(forecast_new))]
|
|
|
198 |
|
199 |
list_with_colour = ['red', 'blue', 'lightgreen', 'gold', 'plum', 'indigo', 'coral', 'plum', 'blue', 'tomato']
|
200 |
r = 1
|
201 |
+
oborot = df_no_feature['Оборот поогноз']
|
202 |
|
203 |
for j in list_with_data_by_features:
|
204 |
# st.write(j)
|
|
|
206 |
forecast_chek = [j[3] for l in range(len(forecast_new))]
|
207 |
new_summ_with_features = []
|
208 |
list_retention = list_retention[:duration+1] + [0 for g in range(25)]
|
209 |
+
summ_from_feature = 0
|
210 |
for i in range(len(forecast_new)):
|
211 |
# st.write(i)
|
212 |
summ_from_feature = 0
|
|
|
217 |
# st.write((forecast_new.index[i].date() >= j[5]) & (
|
218 |
# forecast_new.index[i].date() <= j[5] + timedelta(days=180)))
|
219 |
# oborot = df_no_feature['Оборот']
|
220 |
+
summ_from_feature = j[0] * j[1] * j[2] * forecast_chek[i] * list_retention[i]
|
221 |
# print("Доп сумма от фичи:", summ_from_feature)
|
222 |
# st.write(summ_from_feature)
|
223 |
|
|
|
239 |
fig, ax = plt.subplots(figsize=(10, 5))
|
240 |
# plt.plot(train['Оборот по всем копилкам за месяц'], label='Train')
|
241 |
ax.plot(data['Оборот'], label='Исторические данные', color='orange')
|
242 |
+
ax.plot(forecast_new.index, df_no_feature['Оборот поогноз'], label='Прогноз', color='green', linestyle='--')
|
243 |
for k in range(len(list_with_data_by_features)):
|
244 |
ax.plot(forecast_new.index, df_no_feature[f'Прогноз с учетом фичи # {k+1}'], label=f'Прогноз с добавлением фичи # {k+1}', color=list_with_colour[k], linestyle='--')
|
245 |
|