SUNGJIN LEE
commited on
Commit
•
7f4ef9c
1
Parent(s):
1267686
Time Window 추가
Browse files- Pages/Dashboard.py +1 -1
- Pages/{Recommendation System.py → Recommendation_By_Time.py} +2 -2
- Pages/Time_Window_Recommendation.py +87 -0
- app.py +28 -12
- map.py +1 -1
- map_recommend.py +2 -2
Pages/Dashboard.py
CHANGED
@@ -47,7 +47,7 @@ unique_cells = df['enbid_pci'].unique().tolist()
|
|
47 |
|
48 |
show_chart = st.sidebar.checkbox("차트", True)
|
49 |
if show_chart:
|
50 |
-
selected_cell = st.selectbox("
|
51 |
st.session_state['selected_cell'] = selected_cell
|
52 |
|
53 |
cell_data = df[df['enbid_pci'] == st.session_state['selected_cell']].copy()
|
|
|
47 |
|
48 |
show_chart = st.sidebar.checkbox("차트", True)
|
49 |
if show_chart:
|
50 |
+
selected_cell = st.selectbox("셀 ID:", unique_cells, index=unique_cells.index(st.session_state['selected_cell']) if st.session_state['selected_cell'] in unique_cells else 0)
|
51 |
st.session_state['selected_cell'] = selected_cell
|
52 |
|
53 |
cell_data = df[df['enbid_pci'] == st.session_state['selected_cell']].copy()
|
Pages/{Recommendation System.py → Recommendation_By_Time.py}
RENAMED
@@ -11,7 +11,7 @@ token = data.token
|
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
-
st.write('# Recommendation
|
15 |
|
16 |
# 세션 상태 초기화
|
17 |
if 'selected_model' not in st.session_state:
|
@@ -178,7 +178,7 @@ if st.session_state.map_data:
|
|
178 |
# Cell ID 선택 및 상태 표시
|
179 |
matching_enbid_pci = '33011_221'
|
180 |
unique_cells = df['enbid_pci'].unique().tolist()
|
181 |
-
matching_enbid_pci = st.selectbox('
|
182 |
|
183 |
st.markdown(f"##### **Cell**: {matching_enbid_pci}")
|
184 |
|
|
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
13 |
|
14 |
+
st.write('# Recommendation By Time')
|
15 |
|
16 |
# 세션 상태 초기화
|
17 |
if 'selected_model' not in st.session_state:
|
|
|
178 |
# Cell ID 선택 및 상태 표시
|
179 |
matching_enbid_pci = '33011_221'
|
180 |
unique_cells = df['enbid_pci'].unique().tolist()
|
181 |
+
matching_enbid_pci = st.selectbox('셀 ID:', unique_cells, index=unique_cells.index(matching_enbid_pci) if matching_enbid_pci in unique_cells else 0)
|
182 |
|
183 |
st.markdown(f"##### **Cell**: {matching_enbid_pci}")
|
184 |
|
Pages/Time_Window_Recommendation.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import plotly.graph_objects as go
|
3 |
+
import pandas as pd
|
4 |
+
from datetime import datetime, time
|
5 |
+
from datasets import load_dataset
|
6 |
+
import data
|
7 |
+
|
8 |
+
st.set_page_config(layout="wide")
|
9 |
+
|
10 |
+
st.write("# Time Window Recommendation")
|
11 |
+
|
12 |
+
token = data.token
|
13 |
+
|
14 |
+
@st.cache_data(show_spinner=False)
|
15 |
+
def load_data():
|
16 |
+
dataset = load_dataset('skt-asap/labeled-dataset', data_files="Labeled.csv", token=token)
|
17 |
+
df = dataset['train'].to_pandas()
|
18 |
+
df.fillna(0, inplace=True)
|
19 |
+
|
20 |
+
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
21 |
+
|
22 |
+
return df
|
23 |
+
|
24 |
+
df = load_data()
|
25 |
+
|
26 |
+
unique_cells = df['enbid_pci'].unique().tolist()
|
27 |
+
selected_enbid_pci = st.selectbox('셀 ID:', unique_cells)
|
28 |
+
|
29 |
+
available_dates = df['timestamp'].dt.date.unique()
|
30 |
+
selected_date = st.date_input('날짜 선택:', min_value=min(available_dates), max_value=max(available_dates), value=min(available_dates))
|
31 |
+
|
32 |
+
filtered_df = df[(df['timestamp'].dt.date == selected_date) & (df['enbid_pci'] == selected_enbid_pci)]
|
33 |
+
|
34 |
+
timeline_data = []
|
35 |
+
status_columns = ['Status_2100', 'Status_2600_10', 'Status_2600_20']
|
36 |
+
|
37 |
+
for col in status_columns:
|
38 |
+
daily_status = filtered_df[['timestamp', col]].set_index('timestamp').resample('15T').first()
|
39 |
+
daily_status['start_time'] = daily_status.index
|
40 |
+
daily_status['end_time'] = daily_status['start_time'] + pd.Timedelta(minutes=15)
|
41 |
+
|
42 |
+
for _, row in daily_status.iterrows():
|
43 |
+
if pd.notna(row[col]): # NaN 값 처리
|
44 |
+
timeline_data.append(dict(
|
45 |
+
Task=col,
|
46 |
+
Start=row['start_time'],
|
47 |
+
Finish=row['end_time'],
|
48 |
+
Resource='ON' if row[col] == 1 else 'OFF'
|
49 |
+
))
|
50 |
+
|
51 |
+
timeline_df = pd.DataFrame(timeline_data)
|
52 |
+
|
53 |
+
fig = go.Figure()
|
54 |
+
|
55 |
+
for status in status_columns:
|
56 |
+
status_data = timeline_df[timeline_df['Task'] == status]
|
57 |
+
if not status_data.empty:
|
58 |
+
fig.add_trace(go.Bar(
|
59 |
+
x=[(d['Finish'] - d['Start']).total_seconds() / 3600 for d in status_data.to_dict('records')],
|
60 |
+
y=[status] * len(status_data),
|
61 |
+
orientation='h',
|
62 |
+
name=status,
|
63 |
+
text=status_data['Resource'],
|
64 |
+
textposition='inside',
|
65 |
+
insidetextanchor='middle',
|
66 |
+
marker=dict(color=['#FF8181' if r == 'OFF' else '#7AA1EE' for r in status_data['Resource']])
|
67 |
+
))
|
68 |
+
|
69 |
+
fig.update_layout(
|
70 |
+
title=f'일일 ON/OFF 타임라인 - {selected_enbid_pci} ({selected_date})',
|
71 |
+
xaxis_title='시간',
|
72 |
+
yaxis_title='주파수 대역',
|
73 |
+
height=400,
|
74 |
+
barmode='stack',
|
75 |
+
xaxis=dict(
|
76 |
+
tickmode='array',
|
77 |
+
tickvals=[i for i in range(0, 25, 3)],
|
78 |
+
ticktext=[f'{i:02d}:00' for i in range(0, 25, 3)]
|
79 |
+
),
|
80 |
+
legend_title_text='주파수 대역',
|
81 |
+
margin=dict(l=0, r=0, t=50, b=0)
|
82 |
+
)
|
83 |
+
|
84 |
+
fig.update_traces(textfont_size=10)
|
85 |
+
|
86 |
+
# Streamlit 앱에 차트 추가
|
87 |
+
st.plotly_chart(fig, use_container_width=True)
|
app.py
CHANGED
@@ -23,37 +23,53 @@ def logout():
|
|
23 |
st.session_state.logged_in = False
|
24 |
st.rerun()
|
25 |
|
26 |
-
login_page = st.Page(login, title="
|
27 |
-
logout_page = st.Page(logout, title="
|
28 |
|
29 |
Home = st.Page(
|
30 |
-
"Pages/Home.py",
|
|
|
|
|
31 |
)
|
32 |
About = st.Page(
|
33 |
-
"Pages/About.py",
|
|
|
|
|
34 |
)
|
35 |
|
36 |
Data = st.Page(
|
37 |
-
"Pages/Data.py",
|
|
|
|
|
38 |
)
|
39 |
Algorithm = st.Page(
|
40 |
-
"Pages/Algorithm.py",
|
|
|
|
|
41 |
)
|
42 |
|
43 |
Dashboard = st.Page(
|
44 |
-
"Pages/Dashboard.py",
|
|
|
|
|
45 |
)
|
46 |
-
|
47 |
-
"Pages/
|
48 |
-
title="Recommendation
|
49 |
-
icon=":material/
|
50 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
if st.session_state.logged_in:
|
52 |
pg = st.navigation(
|
53 |
{
|
54 |
"": [Home, About],
|
55 |
# "Development": [Data, Algorithm],
|
56 |
-
"System" : [Dashboard,
|
57 |
"Account": [logout_page]
|
58 |
}
|
59 |
)
|
|
|
23 |
st.session_state.logged_in = False
|
24 |
st.rerun()
|
25 |
|
26 |
+
login_page = st.Page(login, title="Login", icon=":material/login:")
|
27 |
+
logout_page = st.Page(logout, title="Logout", icon=":material/logout:")
|
28 |
|
29 |
Home = st.Page(
|
30 |
+
"Pages/Home.py",
|
31 |
+
title="Home",
|
32 |
+
icon=":material/home:"
|
33 |
)
|
34 |
About = st.Page(
|
35 |
+
"Pages/About.py",
|
36 |
+
title="About",
|
37 |
+
icon=":material/info:"
|
38 |
)
|
39 |
|
40 |
Data = st.Page(
|
41 |
+
"Pages/Data.py",
|
42 |
+
title="Data",
|
43 |
+
icon=":material/data_usage:"
|
44 |
)
|
45 |
Algorithm = st.Page(
|
46 |
+
"Pages/Algorithm.py",
|
47 |
+
title="Algorithm",
|
48 |
+
icon=":material/insights:"
|
49 |
)
|
50 |
|
51 |
Dashboard = st.Page(
|
52 |
+
"Pages/Dashboard.py",
|
53 |
+
title="Dashboard",
|
54 |
+
icon=":material/dashboard:"
|
55 |
)
|
56 |
+
Recommendation_By_Time = st.Page(
|
57 |
+
"Pages/Recommendation_By_Time.py",
|
58 |
+
title="Recommendation By Time",
|
59 |
+
icon=":material/schedule:"
|
60 |
)
|
61 |
+
Time_Window_Recommendation = st.Page(
|
62 |
+
"Pages/Time_Window_Recommendation.py",
|
63 |
+
title="Time Window Recommendation",
|
64 |
+
icon=":material/calendar_view_day:"
|
65 |
+
)
|
66 |
+
|
67 |
if st.session_state.logged_in:
|
68 |
pg = st.navigation(
|
69 |
{
|
70 |
"": [Home, About],
|
71 |
# "Development": [Data, Algorithm],
|
72 |
+
"System" : [Dashboard, Recommendation_By_Time, Time_Window_Recommendation],
|
73 |
"Account": [logout_page]
|
74 |
}
|
75 |
)
|
map.py
CHANGED
@@ -12,7 +12,7 @@ def create_map(dataframe):
|
|
12 |
for idx, row in dataframe.iterrows():
|
13 |
cell_id = row['enbid_pci']
|
14 |
|
15 |
-
color = '#
|
16 |
custom_icon = DivIcon(
|
17 |
html=f"""
|
18 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
|
|
12 |
for idx, row in dataframe.iterrows():
|
13 |
cell_id = row['enbid_pci']
|
14 |
|
15 |
+
color = '#19D18B'
|
16 |
custom_icon = DivIcon(
|
17 |
html=f"""
|
18 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
map_recommend.py
CHANGED
@@ -15,9 +15,9 @@ def create_map(dataframe, recommendations):
|
|
15 |
recommended_cell_state = recommendations.get(cell_id, 'UNKNOWN')
|
16 |
|
17 |
if recommended_cell_state == 'ON':
|
18 |
-
color = '#
|
19 |
elif recommended_cell_state == 'OFF':
|
20 |
-
color = '#
|
21 |
else:
|
22 |
color = '#ccc'
|
23 |
|
|
|
15 |
recommended_cell_state = recommendations.get(cell_id, 'UNKNOWN')
|
16 |
|
17 |
if recommended_cell_state == 'ON':
|
18 |
+
color = '#7AA1EE'
|
19 |
elif recommended_cell_state == 'OFF':
|
20 |
+
color = '#FF8181'
|
21 |
else:
|
22 |
color = '#ccc'
|
23 |
|