Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -106,10 +106,11 @@ def create_slicers(data):
|
|
106 |
)
|
107 |
|
108 |
def apply_slicers(data):
|
|
|
109 |
for col, selected_values in st.session_state.slicers.items():
|
110 |
if selected_values:
|
111 |
-
|
112 |
-
return
|
113 |
|
114 |
def plot_correlation_heatmap(data):
|
115 |
corr = data[st.session_state.numeric_columns].corr()
|
@@ -150,43 +151,46 @@ def plot_scatter_with_regression(data, x_var, y_var):
|
|
150 |
st.write(f"μκ΄κ³μ: {r_value:.4f}")
|
151 |
st.write(f"p-value: {p_value:.4f}")
|
152 |
st.write(f"νμ€ μ€μ°¨: {std_err:.4f}")
|
153 |
-
|
154 |
-
def perform_analysis():
|
155 |
-
st.header("νμμ λ°μ΄ν° λΆμ")
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
|
177 |
-
|
|
|
|
|
178 |
|
179 |
def main():
|
180 |
st.title("μΈν°λν°λΈ EDA ν΄ν·")
|
181 |
|
182 |
manage_session_state()
|
183 |
|
184 |
-
if
|
185 |
data_input_method = st.radio("λ°μ΄ν° μ
λ ₯ λ°©λ² μ ν:", ("νμΌ μ
λ‘λ", "μλ μ
λ ₯"), key="data_input_method")
|
186 |
|
187 |
if data_input_method == "νμΌ μ
λ‘λ":
|
188 |
uploaded_file = st.file_uploader("CSV, XLS, λλ XLSX νμΌμ μ ννμΈμ", type=["csv", "xls", "xlsx"], key="file_uploader")
|
189 |
-
if uploaded_file:
|
190 |
st.session_state.data = load_data(uploaded_file)
|
191 |
else:
|
192 |
st.session_state.data = manual_data_entry()
|
|
|
106 |
)
|
107 |
|
108 |
def apply_slicers(data):
|
109 |
+
filtered_data = data.copy()
|
110 |
for col, selected_values in st.session_state.slicers.items():
|
111 |
if selected_values:
|
112 |
+
filtered_data = filtered_data[filtered_data[col].isin(selected_values)]
|
113 |
+
return filtered_data
|
114 |
|
115 |
def plot_correlation_heatmap(data):
|
116 |
corr = data[st.session_state.numeric_columns].corr()
|
|
|
151 |
st.write(f"μκ΄κ³μ: {r_value:.4f}")
|
152 |
st.write(f"p-value: {p_value:.4f}")
|
153 |
st.write(f"νμ€ μ€μ°¨: {std_err:.4f}")
|
|
|
|
|
|
|
154 |
|
155 |
+
def perform_analysis():
|
156 |
+
if st.session_state.processed_data is not None and not st.session_state.processed_data.empty:
|
157 |
+
st.header("νμμ λ°μ΄ν° λΆμ")
|
158 |
+
|
159 |
+
# μ¬λΌμ΄μ μμ± λ° μ μ©
|
160 |
+
create_slicers(st.session_state.processed_data)
|
161 |
+
filtered_data = apply_slicers(st.session_state.processed_data)
|
162 |
+
|
163 |
+
# μμ½ ν΅κ³
|
164 |
+
st.write("μμ½ ν΅κ³:")
|
165 |
+
st.write(filtered_data.describe())
|
166 |
|
167 |
+
# μκ΄κ΄κ³ ννΈλ§΅
|
168 |
+
st.subheader("μκ΄κ΄κ³ ννΈλ§΅")
|
169 |
+
plot_correlation_heatmap(filtered_data)
|
170 |
+
|
171 |
+
# μ¬μ©μκ° μ νν λ λ³μμ λν μ°μ λ λ° νκ· λΆμ
|
172 |
+
st.subheader("λ λ³μ κ°μ κ΄κ³ λΆμ")
|
173 |
+
st.session_state.x_var = st.selectbox("XμΆ λ³μ μ ν", options=st.session_state.numeric_columns, key='x_var')
|
174 |
+
st.session_state.y_var = st.selectbox("YμΆ λ³μ μ ν", options=[col for col in st.session_state.numeric_columns if col != st.session_state.x_var], key='y_var')
|
175 |
|
176 |
+
if st.session_state.x_var and st.session_state.y_var:
|
177 |
+
plot_scatter_with_regression(filtered_data, st.session_state.x_var, st.session_state.y_var)
|
178 |
|
179 |
+
st.session_state.analysis_performed = True
|
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 |
data_input_method = st.radio("λ°μ΄ν° μ
λ ₯ λ°©λ² μ ν:", ("νμΌ μ
λ‘λ", "μλ μ
λ ₯"), key="data_input_method")
|
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()
|