Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -180,29 +180,72 @@ def perform_analysis():
|
|
180 |
else:
|
181 |
st.warning("λΆμν λ°μ΄ν°κ° μμ΅λλ€. λ°μ΄ν°λ₯Ό λ¨Όμ λ‘λνκ³ μ μ²λ¦¬ν΄μ£ΌμΈμ.")
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
def main():
|
184 |
st.title("μΈν°λν°λΈ EDA ν΄ν·")
|
185 |
|
186 |
manage_session_state()
|
187 |
|
188 |
-
if st.session_state.data is None:
|
189 |
-
|
190 |
-
|
191 |
-
if data_input_method == "νμΌ μ
λ‘λ":
|
192 |
-
uploaded_file = st.file_uploader("CSV, XLS, λλ XLSX νμΌμ μ ννμΈμ", type=["csv", "xls", "xlsx"], key="file_uploader")
|
193 |
-
if uploaded_file is not None:
|
194 |
-
st.session_state.data = load_data(uploaded_file)
|
195 |
-
else:
|
196 |
-
st.session_state.data = manual_data_entry()
|
197 |
-
|
198 |
if st.session_state.data is not None:
|
199 |
st.subheader("λ°μ΄ν° 미리보기 λ° μμ ")
|
200 |
st.write("λ°μ΄ν°λ₯Ό νμΈνκ³ νμν κ²½μ° μμ νμΈμ:")
|
201 |
edited_data = st.data_editor(st.session_state.data, num_rows="dynamic", key="data_editor")
|
202 |
|
203 |
-
if st.button("λ°μ΄ν° λΆμ μμ", key="start_analysis") or st.session_state.analysis_performed:
|
204 |
-
if not st.session_state.analysis_performed:
|
205 |
st.session_state.processed_data = preprocess_data(edited_data)
|
|
|
206 |
perform_analysis()
|
207 |
|
208 |
if __name__ == "__main__":
|
|
|
180 |
else:
|
181 |
st.warning("λΆμν λ°μ΄ν°κ° μμ΅λλ€. λ°μ΄ν°λ₯Ό λ¨Όμ λ‘λνκ³ μ μ²λ¦¬ν΄μ£ΌμΈμ.")
|
182 |
|
183 |
+
|
184 |
+
# state μ μ§νλλ‘ μΆκ°
|
185 |
+
|
186 |
+
def update_filtered_data():
|
187 |
+
st.session_state.filtered_data = apply_slicers(st.session_state.processed_data)
|
188 |
+
|
189 |
+
def create_slicers(data):
|
190 |
+
for col in st.session_state.categorical_columns:
|
191 |
+
if data[col].nunique() <= 10:
|
192 |
+
st.session_state.slicers[col] = st.multiselect(
|
193 |
+
f"{col} μ ν",
|
194 |
+
options=sorted(data[col].unique()),
|
195 |
+
default=sorted(data[col].unique()),
|
196 |
+
key=f"slicer_{col}",
|
197 |
+
on_change=update_filtered_data
|
198 |
+
)
|
199 |
+
|
200 |
+
def apply_slicers(data):
|
201 |
+
filtered_data = data.copy()
|
202 |
+
for col, selected_values in st.session_state.slicers.items():
|
203 |
+
if selected_values:
|
204 |
+
filtered_data = filtered_data[filtered_data[col].isin(selected_values)]
|
205 |
+
return filtered_data
|
206 |
+
|
207 |
+
def perform_analysis():
|
208 |
+
if 'filtered_data' not in st.session_state or st.session_state.filtered_data is None:
|
209 |
+
st.session_state.filtered_data = st.session_state.processed_data.copy()
|
210 |
+
|
211 |
+
st.header("νμμ λ°μ΄ν° λΆμ")
|
212 |
+
|
213 |
+
# μ¬λΌμ΄μ μμ±
|
214 |
+
create_slicers(st.session_state.processed_data)
|
215 |
+
|
216 |
+
# μμ½ ν΅κ³
|
217 |
+
st.write("μμ½ ν΅κ³:")
|
218 |
+
st.write(st.session_state.filtered_data.describe())
|
219 |
+
|
220 |
+
# μκ΄κ΄κ³ ννΈλ§΅
|
221 |
+
st.subheader("μκ΄κ΄κ³ ννΈλ§΅")
|
222 |
+
plot_correlation_heatmap(st.session_state.filtered_data)
|
223 |
+
|
224 |
+
# μ¬μ©μκ° μ νν λ λ³μμ λν μ°μ λ λ° νκ· λΆμ
|
225 |
+
st.subheader("λ λ³μ κ°μ κ΄κ³ λΆμ")
|
226 |
+
x_var = st.selectbox("XμΆ λ³μ μ ν", options=st.session_state.numeric_columns, key='x_var')
|
227 |
+
y_var = st.selectbox("YμΆ λ³μ μ ν", options=[col for col in st.session_state.numeric_columns if col != x_var], key='y_var')
|
228 |
+
|
229 |
+
if x_var and y_var:
|
230 |
+
plot_scatter_with_regression(st.session_state.filtered_data, x_var, y_var)
|
231 |
+
|
232 |
def main():
|
233 |
st.title("μΈν°λν°λΈ EDA ν΄ν·")
|
234 |
|
235 |
manage_session_state()
|
236 |
|
237 |
+
if 'data' not in st.session_state or st.session_state.data is None:
|
238 |
+
# ... (λ°μ΄ν° λ‘λ λΆλΆ)
|
239 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
if st.session_state.data is not None:
|
241 |
st.subheader("λ°μ΄ν° 미리보기 λ° μμ ")
|
242 |
st.write("λ°μ΄ν°λ₯Ό νμΈνκ³ νμν κ²½μ° μμ νμΈμ:")
|
243 |
edited_data = st.data_editor(st.session_state.data, num_rows="dynamic", key="data_editor")
|
244 |
|
245 |
+
if st.button("λ°μ΄ν° λΆμ μμ", key="start_analysis") or ('analysis_performed' in st.session_state and st.session_state.analysis_performed):
|
246 |
+
if 'analysis_performed' not in st.session_state or not st.session_state.analysis_performed:
|
247 |
st.session_state.processed_data = preprocess_data(edited_data)
|
248 |
+
st.session_state.analysis_performed = True
|
249 |
perform_analysis()
|
250 |
|
251 |
if __name__ == "__main__":
|