Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,8 @@ import plotly.express as px
|
|
5 |
import plotly.graph_objects as go
|
6 |
from io import StringIO
|
7 |
import openpyxl
|
8 |
-
import matplotlib.pyplot as plt
|
9 |
import matplotlib.font_manager as fm
|
|
|
10 |
|
11 |
# ํ๊ธ ํฐํธ ์ค์
|
12 |
def set_font():
|
@@ -89,38 +89,121 @@ def perform_analysis(data):
|
|
89 |
else:
|
90 |
st.write("์๊ด๊ด๊ณ ํํธ๋งต์ ๊ทธ๋ฆด ์ ์๋ ์ซ์ํ ์ด์ด ์์ต๋๋ค.")
|
91 |
|
92 |
-
#
|
93 |
-
|
94 |
-
|
95 |
-
fig = px.
|
96 |
-
fig.update_layout(title='
|
97 |
st.plotly_chart(fig)
|
98 |
-
else:
|
99 |
-
st.write("์ฐ์ ๋ ํ๋ ฌ์ ๊ทธ๋ฆด ์ ์๋ ์ซ์ํ ์ด์ด ์์ต๋๋ค.")
|
100 |
|
101 |
-
#
|
102 |
-
|
103 |
-
|
104 |
-
fig = px.
|
105 |
-
fig.update_layout(title=
|
106 |
st.plotly_chart(fig)
|
107 |
|
108 |
-
#
|
109 |
-
|
110 |
-
|
111 |
-
fig = px.
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
st.plotly_chart(fig)
|
114 |
|
115 |
-
#
|
116 |
-
|
117 |
-
if
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
st.plotly_chart(fig)
|
125 |
|
126 |
def main():
|
|
|
5 |
import plotly.graph_objects as go
|
6 |
from io import StringIO
|
7 |
import openpyxl
|
|
|
8 |
import matplotlib.font_manager as fm
|
9 |
+
from scipy import stats
|
10 |
|
11 |
# ํ๊ธ ํฐํธ ์ค์
|
12 |
def set_font():
|
|
|
89 |
else:
|
90 |
st.write("์๊ด๊ด๊ณ ํํธ๋งต์ ๊ทธ๋ฆด ์ ์๋ ์ซ์ํ ์ด์ด ์์ต๋๋ค.")
|
91 |
|
92 |
+
# ๊ณผ๋ชฉ๋ณ ์ ์ ๋ถํฌ
|
93 |
+
if '๊ณผ๋ชฉ' in data.columns and 'ํ์ตํ๊ฐ' in data.columns:
|
94 |
+
st.write("๊ณผ๋ชฉ๋ณ ์ ์ ๋ถํฌ:")
|
95 |
+
fig = px.box(data, x='๊ณผ๋ชฉ', y='ํ์ตํ๊ฐ', points="all")
|
96 |
+
fig.update_layout(title='๊ณผ๋ชฉ๋ณ ํ์ตํ๊ฐ ์ ์ ๋ถํฌ')
|
97 |
st.plotly_chart(fig)
|
|
|
|
|
98 |
|
99 |
+
# ์๋ณ ์ ์ ์ถ์ด
|
100 |
+
if '๋ฌ' in data.columns and 'ํ์ตํ๊ฐ' in data.columns:
|
101 |
+
st.write("์๋ณ ์ ์ ์ถ์ด:")
|
102 |
+
fig = px.line(data, x='๋ฌ', y='ํ์ตํ๊ฐ', color='๊ณผ๋ชฉ', markers=True)
|
103 |
+
fig.update_layout(title='์๋ณ ํ์ตํ๊ฐ ์ ์ ์ถ์ด')
|
104 |
st.plotly_chart(fig)
|
105 |
|
106 |
+
# ์๊ธฐ๋
ธ๋ ฅ๋์ ํ์ตํ๊ฐ ๊ด๊ณ (ํ๊ท์ ๊ณผ R-squared ์ถ๊ฐ)
|
107 |
+
if '์๊ธฐ๋
ธ๋ ฅ๋' in data.columns and 'ํ์ตํ๊ฐ' in data.columns:
|
108 |
+
st.write("์๊ธฐ๋
ธ๋ ฅ๋์ ํ์ตํ๊ฐ ๊ด๊ณ:")
|
109 |
+
fig = px.scatter(data, x='์๊ธฐ๋
ธ๋ ฅ๋', y='ํ์ตํ๊ฐ', color='๊ณผ๋ชฉ', hover_data=['๋ฌ'])
|
110 |
+
|
111 |
+
# ์ ์ฒด ๋ฐ์ดํฐ์ ๋ํ ํ๊ท์ ์ถ๊ฐ
|
112 |
+
x = data['์๊ธฐ๋
ธ๋ ฅ๋']
|
113 |
+
y = data['ํ์ตํ๊ฐ']
|
114 |
+
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
|
115 |
+
line_x = np.array([x.min(), x.max()])
|
116 |
+
line_y = slope * line_x + intercept
|
117 |
+
fig.add_trace(go.Scatter(x=line_x, y=line_y, mode='lines', name='ํ๊ท์ '))
|
118 |
+
|
119 |
+
r_squared = r_value ** 2
|
120 |
+
fig.update_layout(
|
121 |
+
title=f'์๊ธฐ๋
ธ๋ ฅ๋์ ํ์ตํ๊ฐ ๊ด๊ณ (R-squared: {r_squared:.4f})',
|
122 |
+
annotations=[
|
123 |
+
dict(
|
124 |
+
x=0.5,
|
125 |
+
y=1.05,
|
126 |
+
xref='paper',
|
127 |
+
yref='paper',
|
128 |
+
text=f'R-squared: {r_squared:.4f}',
|
129 |
+
showarrow=False,
|
130 |
+
)
|
131 |
+
]
|
132 |
+
)
|
133 |
st.plotly_chart(fig)
|
134 |
|
135 |
+
# ์ธํฐ๋ํฐ๋ธ ํํฐ๋ง
|
136 |
+
st.write("์ธํฐ๋ํฐ๋ธ ํํฐ๋ง:")
|
137 |
+
if '์๊ธฐ๋
ธ๋ ฅ๋' in data.columns:
|
138 |
+
min_effort = int(data['์๊ธฐ๋
ธ๋ ฅ๋'].min())
|
139 |
+
max_effort = int(data['์๊ธฐ๋
ธ๋ ฅ๋'].max())
|
140 |
+
effort_range = st.slider("์๊ธฐ๋
ธ๋ ฅ๋ ๋ฒ์ ์ ํ", min_effort, max_effort, (min_effort, max_effort))
|
141 |
+
|
142 |
+
filtered_data = data[(data['์๊ธฐ๋
ธ๋ ฅ๋'] >= effort_range[0]) & (data['์๊ธฐ๋
ธ๋ ฅ๋'] <= effort_range[1])]
|
143 |
+
|
144 |
+
if '๊ณผ๋ชฉ' in filtered_data.columns and 'ํ์ตํ๊ฐ' in filtered_data.columns:
|
145 |
+
fig = px.scatter(filtered_data, x='์๊ธฐ๋
ธ๋ ฅ๋', y='ํ์ตํ๊ฐ', color='๊ณผ๋ชฉ', hover_data=['๋ฌ'])
|
146 |
+
|
147 |
+
# ํํฐ๋ง๋ ๋ฐ์ดํฐ์ ๋ํ ํ๊ท์ ์ถ๊ฐ
|
148 |
+
x = filtered_data['์๊ธฐ๋
ธ๋ ฅ๋']
|
149 |
+
y = filtered_data['ํ์ตํ๊ฐ']
|
150 |
+
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
|
151 |
+
line_x = np.array([x.min(), x.max()])
|
152 |
+
line_y = slope * line_x + intercept
|
153 |
+
fig.add_trace(go.Scatter(x=line_x, y=line_y, mode='lines', name='ํ๊ท์ '))
|
154 |
+
|
155 |
+
r_squared = r_value ** 2
|
156 |
+
fig.update_layout(
|
157 |
+
title=f'์๊ธฐ๋
ธ๋ ฅ๋ {effort_range[0]}-{effort_range[1]} ๋ฒ์์ ํ์ตํ๊ฐ ๊ด๊ณ (R-squared: {r_squared:.4f})',
|
158 |
+
annotations=[
|
159 |
+
dict(
|
160 |
+
x=0.5,
|
161 |
+
y=1.05,
|
162 |
+
xref='paper',
|
163 |
+
yref='paper',
|
164 |
+
text=f'R-squared: {r_squared:.4f}',
|
165 |
+
showarrow=False,
|
166 |
+
)
|
167 |
+
]
|
168 |
+
)
|
169 |
+
st.plotly_chart(fig)
|
170 |
+
|
171 |
+
# ๊ณผ๋ชฉ๋ณ ์์ธ ๋ถ์
|
172 |
+
if '๊ณผ๋ชฉ' in data.columns:
|
173 |
+
st.write("๊ณผ๋ชฉ๋ณ ์์ธ ๋ถ์:")
|
174 |
+
selected_subject = st.selectbox("๋ถ์ํ ๊ณผ๋ชฉ ์ ํ", data['๊ณผ๋ชฉ'].unique())
|
175 |
+
subject_data = data[data['๊ณผ๋ชฉ'] == selected_subject]
|
176 |
+
|
177 |
+
if '๋ฌ' in subject_data.columns and 'ํ์ตํ๊ฐ' in subject_data.columns:
|
178 |
+
fig = px.line(subject_data, x='๋ฌ', y='ํ์ตํ๊ฐ', markers=True)
|
179 |
+
fig.update_layout(title=f'{selected_subject} ์๋ณ ํ์ตํ๊ฐ ์ ์ ์ถ์ด')
|
180 |
+
st.plotly_chart(fig)
|
181 |
+
|
182 |
+
if '์๊ธฐ๋
ธ๋ ฅ๋' in subject_data.columns and 'ํ์ตํ๊ฐ' in subject_data.columns:
|
183 |
+
fig = px.scatter(subject_data, x='์๊ธฐ๋
ธ๋ ฅ๋', y='ํ์ตํ๊ฐ', hover_data=['๋ฌ'])
|
184 |
+
|
185 |
+
# ์ ํ๋ ๊ณผ๋ชฉ์ ๋ํ ํ๊ท์ ์ถ๊ฐ
|
186 |
+
x = subject_data['์๊ธฐ๋
ธ๋ ฅ๋']
|
187 |
+
y = subject_data['ํ์ตํ๊ฐ']
|
188 |
+
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
|
189 |
+
line_x = np.array([x.min(), x.max()])
|
190 |
+
line_y = slope * line_x + intercept
|
191 |
+
fig.add_trace(go.Scatter(x=line_x, y=line_y, mode='lines', name='ํ๊ท์ '))
|
192 |
+
|
193 |
+
r_squared = r_value ** 2
|
194 |
+
fig.update_layout(
|
195 |
+
title=f'{selected_subject} ์๊ธฐ๋
ธ๋ ฅ๋์ ํ์ตํ๊ฐ ๊ด๊ณ (R-squared: {r_squared:.4f})',
|
196 |
+
annotations=[
|
197 |
+
dict(
|
198 |
+
x=0.5,
|
199 |
+
y=1.05,
|
200 |
+
xref='paper',
|
201 |
+
yref='paper',
|
202 |
+
text=f'R-squared: {r_squared:.4f}',
|
203 |
+
showarrow=False,
|
204 |
+
)
|
205 |
+
]
|
206 |
+
)
|
207 |
st.plotly_chart(fig)
|
208 |
|
209 |
def main():
|