SUNGJIN LEE
commited on
Commit
•
7573141
1
Parent(s):
55e7c55
Random 데이터셋 추가
Browse files- data.py +3 -3
- pages/Recommendation System.py +33 -8
data.py
CHANGED
@@ -6,15 +6,15 @@ import os
|
|
6 |
token = os.getenv('HF_TOKEN')
|
7 |
|
8 |
data_files = {
|
9 |
-
"
|
10 |
-
"
|
11 |
}
|
12 |
|
13 |
@st.cache_data(show_spinner=False)
|
14 |
def load_data():
|
15 |
|
16 |
dataset = load_dataset('skt-asap/busan-poc-dataset', data_files=data_files, token=token)
|
17 |
-
df = dataset['
|
18 |
|
19 |
df.fillna(0, inplace=True)
|
20 |
df.drop(columns=['Unnamed: 0'], inplace=True)
|
|
|
6 |
token = os.getenv('HF_TOKEN')
|
7 |
|
8 |
data_files = {
|
9 |
+
"Part_A": "ELG_Busan_PoC_per_CA_site_0226_0407.csv",
|
10 |
+
"Part_B": "ELG_Busan_PoC_per_CA_site_0408_0519.csv"
|
11 |
}
|
12 |
|
13 |
@st.cache_data(show_spinner=False)
|
14 |
def load_data():
|
15 |
|
16 |
dataset = load_dataset('skt-asap/busan-poc-dataset', data_files=data_files, token=token)
|
17 |
+
df = dataset['Part_A'].to_pandas()
|
18 |
|
19 |
df.fillna(0, inplace=True)
|
20 |
df.drop(columns=['Unnamed: 0'], inplace=True)
|
pages/Recommendation System.py
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import pandas as pd
|
3 |
from datetime import datetime, time
|
4 |
from streamlit_folium import folium_static as st_folium
|
5 |
import map_recommend
|
6 |
import data
|
|
|
|
|
|
|
7 |
|
8 |
st.set_page_config(layout="centered")
|
9 |
|
@@ -42,7 +46,7 @@ def load_and_predict(model_name, df_map, timestamp_input, frequencies, progress_
|
|
42 |
if progress_callback:
|
43 |
progress_callback(10)
|
44 |
|
45 |
-
if model_name == 'CSV
|
46 |
df = st.session_state.uploaded_csv
|
47 |
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
48 |
timestamp_input = pd.to_datetime(timestamp_input)
|
@@ -52,6 +56,18 @@ def load_and_predict(model_name, df_map, timestamp_input, frequencies, progress_
|
|
52 |
st.stop()
|
53 |
else:
|
54 |
df = df[df['timestamp'] == timestamp_input]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
for freq in frequencies:
|
57 |
if model_name == 'Time-based':
|
@@ -62,7 +78,7 @@ def load_and_predict(model_name, df_map, timestamp_input, frequencies, progress_
|
|
62 |
recommended_cell_states[freq][row['enbid_pci']] = 'ON'
|
63 |
if progress_callback:
|
64 |
progress_callback(10 + 80 * (idx + 1) // len(df_map))
|
65 |
-
elif model_name == 'CSV
|
66 |
if st.session_state.uploaded_csv is not None:
|
67 |
for idx, row in df.iterrows():
|
68 |
if row[f'Status_{freq}'] == 0:
|
@@ -74,19 +90,28 @@ def load_and_predict(model_name, df_map, timestamp_input, frequencies, progress_
|
|
74 |
else:
|
75 |
st.error('CSV 파일을 업로드해주세요.')
|
76 |
st.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
|
|
|
80 |
|
81 |
return recommended_cell_states
|
82 |
|
83 |
frequencies_to_check = ['2100', '2600_10', '2600_20']
|
84 |
|
85 |
-
model_options = ['
|
86 |
selected_model = st.selectbox('모델:', model_options, index=model_options.index(st.session_state.selected_model) if st.session_state.selected_model else 0)
|
87 |
|
88 |
-
if selected_model == 'CSV
|
89 |
-
uploaded_file = st.file_uploader("CSV
|
90 |
if uploaded_file is not None:
|
91 |
st.session_state.uploaded_csv = pd.read_csv(uploaded_file)
|
92 |
|
@@ -142,7 +167,7 @@ if st.session_state.map_data:
|
|
142 |
iframe {
|
143 |
max-width: 2000px;
|
144 |
width: 100%;
|
145 |
-
height:
|
146 |
border-radius: 10px;
|
147 |
border: 1px solid #d3d3d3;
|
148 |
}
|
|
|
1 |
import streamlit as st
|
2 |
+
from datasets import load_dataset
|
3 |
import pandas as pd
|
4 |
from datetime import datetime, time
|
5 |
from streamlit_folium import folium_static as st_folium
|
6 |
import map_recommend
|
7 |
import data
|
8 |
+
import os
|
9 |
+
|
10 |
+
token = os.getenv('HF_TOKEN')
|
11 |
|
12 |
st.set_page_config(layout="centered")
|
13 |
|
|
|
46 |
if progress_callback:
|
47 |
progress_callback(10)
|
48 |
|
49 |
+
if model_name == 'CSV File' and st.session_state.uploaded_csv is not None:
|
50 |
df = st.session_state.uploaded_csv
|
51 |
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
52 |
timestamp_input = pd.to_datetime(timestamp_input)
|
|
|
56 |
st.stop()
|
57 |
else:
|
58 |
df = df[df['timestamp'] == timestamp_input]
|
59 |
+
elif model_name == 'Random':
|
60 |
+
with st.spinner('Random 데이터셋 로딩 중...'):
|
61 |
+
dataset = load_dataset('skt-asap/examples', data_files='Random.csv', token=token)
|
62 |
+
df = dataset['train'].to_pandas()
|
63 |
+
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
64 |
+
timestamp_input = pd.to_datetime(timestamp_input)
|
65 |
+
st.info(f"**{df['timestamp'].min().strftime('%Y/%m/%d')} ~ {df['timestamp'].max().strftime('%Y/%m/%d')}** 사이의 날짜를 입력해주세요.")
|
66 |
+
if timestamp_input not in df['timestamp'].values:
|
67 |
+
st.error('CSV 파일에 해당 타임스탬프가 없습니다.')
|
68 |
+
st.stop()
|
69 |
+
else:
|
70 |
+
df = df[df['timestamp'] == timestamp_input]
|
71 |
|
72 |
for freq in frequencies:
|
73 |
if model_name == 'Time-based':
|
|
|
78 |
recommended_cell_states[freq][row['enbid_pci']] = 'ON'
|
79 |
if progress_callback:
|
80 |
progress_callback(10 + 80 * (idx + 1) // len(df_map))
|
81 |
+
elif model_name == 'CSV File':
|
82 |
if st.session_state.uploaded_csv is not None:
|
83 |
for idx, row in df.iterrows():
|
84 |
if row[f'Status_{freq}'] == 0:
|
|
|
90 |
else:
|
91 |
st.error('CSV 파일을 업로드해주세요.')
|
92 |
st.stop()
|
93 |
+
elif model_name == 'Random':
|
94 |
+
for idx, row in df.iterrows():
|
95 |
+
if row[f'Status_{freq}'] == 0:
|
96 |
+
recommended_cell_states[freq][row['enbid_pci']] = 'OFF'
|
97 |
+
elif row[f'Status_{freq}'] == 1:
|
98 |
+
recommended_cell_states[freq][row['enbid_pci']] = 'ON'
|
99 |
+
else:
|
100 |
+
recommended_cell_states[freq][row['enbid_pci']] = 'UNKNOWN'
|
101 |
|
102 |
+
else:
|
103 |
+
st.error('올바른 모델을 선택해주세요.')
|
104 |
+
st.stop()
|
105 |
|
106 |
return recommended_cell_states
|
107 |
|
108 |
frequencies_to_check = ['2100', '2600_10', '2600_20']
|
109 |
|
110 |
+
model_options = ['CSV File', 'Random', 'Time-based']
|
111 |
selected_model = st.selectbox('모델:', model_options, index=model_options.index(st.session_state.selected_model) if st.session_state.selected_model else 0)
|
112 |
|
113 |
+
if selected_model == 'CSV File':
|
114 |
+
uploaded_file = st.file_uploader("CSV File Upload", type="csv", label_visibility='collapsed')
|
115 |
if uploaded_file is not None:
|
116 |
st.session_state.uploaded_csv = pd.read_csv(uploaded_file)
|
117 |
|
|
|
167 |
iframe {
|
168 |
max-width: 2000px;
|
169 |
width: 100%;
|
170 |
+
height: 300px;
|
171 |
border-radius: 10px;
|
172 |
border: 1px solid #d3d3d3;
|
173 |
}
|