Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -51,52 +51,41 @@ normalized_df = pd.DataFrame(normalized_data, columns=[col for col in data.colum
|
|
51 |
normalized_df['year'] = data['year'].values
|
52 |
|
53 |
# Функция предсказания
|
54 |
-
|
55 |
-
|
56 |
-
num_unagegroup_30_39, num_emagegroup_30_39):
|
57 |
if territory not in territory_mapping:
|
58 |
-
return "
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
return
|
80 |
|
81 |
# Интерфейс Gradio
|
82 |
interface = gr.Interface(
|
83 |
-
fn=
|
84 |
inputs=[
|
85 |
-
gr.Dropdown(label="
|
86 |
-
gr.Number(label="Year"),
|
87 |
-
gr.Number(label="Economic Active Population"),
|
88 |
-
gr.Number(label="Employed Population"),
|
89 |
-
gr.Number(label="Unemployed Population"),
|
90 |
-
gr.Number(label="Economic Activity Level"),
|
91 |
-
gr.Number(label="Employment Level"),
|
92 |
-
gr.Number(label="Disunemployed Age Group 30-39"),
|
93 |
-
gr.Number(label="Disemployed Age Group 30-39"),
|
94 |
-
gr.Number(label="Unemployed Age Group 30-39"),
|
95 |
-
gr.Number(label="Employed Age Group 30-39")
|
96 |
],
|
97 |
-
outputs=gr.Textbox(label="
|
98 |
-
title="
|
99 |
-
description="
|
100 |
)
|
101 |
|
102 |
interface.launch()
|
|
|
51 |
normalized_df['year'] = data['year'].values
|
52 |
|
53 |
# Функция предсказания
|
54 |
+
|
55 |
+
def predict_unemployment(territory):
|
|
|
56 |
if territory not in territory_mapping:
|
57 |
+
return "Неверное название территории. Пожалуйста, выберите из списка."
|
58 |
+
|
59 |
+
predictions = []
|
60 |
+
current_year = data['year'].max() + 1
|
61 |
+
|
62 |
+
for i in range(5):
|
63 |
+
sample_row = data[data['territory'] == territory_mapping[territory]].iloc[-1].copy()
|
64 |
+
sample_row['year'] = current_year
|
65 |
+
input_data = sample_row.drop('year').values.reshape(1, -1)
|
66 |
+
|
67 |
+
# Нормализация входных данных
|
68 |
+
input_normalized = scaler.transform(input_data)
|
69 |
+
input_sequence = np.expand_dims(input_normalized, axis=0)
|
70 |
+
|
71 |
+
# Прогноз
|
72 |
+
prediction = model.predict(input_sequence)
|
73 |
+
predictions.append((current_year, round(prediction[0][0] * 100, 2)))
|
74 |
+
|
75 |
+
# Обновление года
|
76 |
+
current_year += 1
|
77 |
+
|
78 |
+
return "\n".join([f"{year}: {value}%" for year, value in predictions])
|
79 |
|
80 |
# Интерфейс Gradio
|
81 |
interface = gr.Interface(
|
82 |
+
fn=predict_unemployment,
|
83 |
inputs=[
|
84 |
+
gr.Dropdown(label="Территория", choices=list(territory_mapping.keys()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
],
|
86 |
+
outputs=gr.Textbox(label="Прогноз на ближайшие 5 лет"),
|
87 |
+
title="Модель прогнозирования уровня безработицы",
|
88 |
+
description="Выберите территорию для прогноза уровня безработицы на ближайшие 5 лет."
|
89 |
)
|
90 |
|
91 |
interface.launch()
|