JUNGU commited on
Commit
eacbd49
Β·
verified Β·
1 Parent(s): 71227fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -88,6 +88,7 @@ def apply_slicers(data, slicers):
88
  data = data[data[col].isin(selected_values)]
89
  return data
90
 
 
91
  def perform_analysis(data):
92
  st.header("탐색적 데이터 뢄석")
93
 
@@ -111,14 +112,18 @@ def perform_analysis(data):
111
  else:
112
  st.write("상관관계 νžˆνŠΈλ§΅μ„ 그릴 수 μžˆλŠ” μˆ«μžν˜• 열이 μ—†μŠ΅λ‹ˆλ‹€.")
113
 
114
- # μΆœμ„μΌμˆ˜μ™€ 성적 관계 뢄석
115
- if 'μΆœμ„μΌμˆ˜' in filtered_data.columns and '성적' in filtered_data.columns:
116
- st.write("μΆœμ„μΌμˆ˜μ™€ 성적 관계:")
117
- fig = px.scatter(filtered_data, x='μΆœμ„μΌμˆ˜', y='성적', color='반', hover_data=filtered_data.columns)
 
 
 
 
118
 
119
- # 전체 데이터에 λŒ€ν•œ νšŒκ·€μ„  μΆ”κ°€
120
- x = filtered_data['μΆœμ„μΌμˆ˜']
121
- y = filtered_data['성적']
122
  slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
123
  line_x = np.array([x.min(), x.max()])
124
  line_y = slope * line_x + intercept
@@ -126,7 +131,9 @@ def perform_analysis(data):
126
 
127
  r_squared = r_value ** 2
128
  fig.update_layout(
129
- title=f'μΆœμ„μΌμˆ˜μ™€ 성적 관계 (R-squared: {r_squared:.4f})',
 
 
130
  annotations=[
131
  dict(
132
  x=0.5,
@@ -140,20 +147,10 @@ def perform_analysis(data):
140
  )
141
  st.plotly_chart(fig)
142
 
143
- # λ°˜λ³„ 성적 뢄포
144
- if '반' in filtered_data.columns and '성적' in filtered_data.columns:
145
- st.write("λ°˜λ³„ 성적 뢄포:")
146
- fig = px.box(filtered_data, x='반', y='성적', points="all")
147
- fig.update_layout(title='λ°˜λ³„ 성적 뢄포')
148
- st.plotly_chart(fig)
149
-
150
- # μΆœμ„μΌμˆ˜ ꡬ간별 성적 뢄포
151
- if 'μΆœμ„μΌμˆ˜' in filtered_data.columns and '성적' in filtered_data.columns:
152
- st.write("μΆœμ„μΌμˆ˜ ꡬ간별 성적 뢄포:")
153
- filtered_data['μΆœμ„μΌμˆ˜_ꡬ간'] = pd.cut(filtered_data['μΆœμ„μΌμˆ˜'], bins=5)
154
- fig = px.box(filtered_data, x='μΆœμ„μΌμˆ˜_ꡬ간', y='성적', color='반')
155
- fig.update_layout(title='μΆœμ„μΌμˆ˜ ꡬ간별 성적 뢄포')
156
- st.plotly_chart(fig)
157
 
158
  def main():
159
  st.title("μΈν„°λž™ν‹°λΈŒ EDA νˆ΄ν‚·")
 
88
  data = data[data[col].isin(selected_values)]
89
  return data
90
 
91
+
92
  def perform_analysis(data):
93
  st.header("탐색적 데이터 뢄석")
94
 
 
112
  else:
113
  st.write("상관관계 νžˆνŠΈλ§΅μ„ 그릴 수 μžˆλŠ” μˆ«μžν˜• 열이 μ—†μŠ΅λ‹ˆλ‹€.")
114
 
115
+ # μ‚¬μš©μžκ°€ μ„ νƒν•œ 두 λ³€μˆ˜μ— λŒ€ν•œ 산점도 및 νšŒκ·€ 뢄석
116
+ st.subheader("두 λ³€μˆ˜ κ°„μ˜ 관계 뢄석")
117
+ numeric_columns = filtered_data.select_dtypes(include=['float64', 'int64']).columns
118
+ x_var = st.selectbox("XμΆ• λ³€μˆ˜ 선택", options=numeric_columns)
119
+ y_var = st.selectbox("YμΆ• λ³€μˆ˜ 선택", options=[col for col in numeric_columns if col != x_var])
120
+
121
+ if x_var and y_var:
122
+ fig = px.scatter(filtered_data, x=x_var, y=y_var, color='반' if '반' in filtered_data.columns else None)
123
 
124
+ # νšŒκ·€μ„  μΆ”κ°€
125
+ x = filtered_data[x_var]
126
+ y = filtered_data[y_var]
127
  slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
128
  line_x = np.array([x.min(), x.max()])
129
  line_y = slope * line_x + intercept
 
131
 
132
  r_squared = r_value ** 2
133
  fig.update_layout(
134
+ title=f'{x_var}와 {y_var}의 관계 (R-squared: {r_squared:.4f})',
135
+ xaxis_title=x_var,
136
+ yaxis_title=y_var,
137
  annotations=[
138
  dict(
139
  x=0.5,
 
147
  )
148
  st.plotly_chart(fig)
149
 
150
+ # μΆ”κ°€ 톡계 정보
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 main():
156
  st.title("μΈν„°λž™ν‹°λΈŒ EDA νˆ΄ν‚·")