Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +86 -164
src/streamlit_app.py
CHANGED
|
@@ -10,99 +10,50 @@ import matplotlib.font_manager as fm
|
|
| 10 |
import warnings
|
| 11 |
warnings.filterwarnings('ignore')
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
def
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
# matplotlib ๋ฐฑ์๋ ์ค์
|
| 18 |
-
plt.switch_backend('Agg')
|
| 19 |
-
|
| 20 |
-
# ๊ธฐ์กด ์ค์ ์์ ์ด๊ธฐํ
|
| 21 |
-
plt.rcdefaults()
|
| 22 |
-
|
| 23 |
-
# ํฐํธ ์บ์ ์์ ์ญ์ ๋ฐ ์ฌ๊ตฌ์ฑ
|
| 24 |
try:
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
'C:/Windows/Fonts/malgun.ttf',
|
| 35 |
-
'C:/Windows/Fonts/gulim.ttc',
|
| 36 |
-
'C:/Windows/Fonts/batang.ttc',
|
| 37 |
-
]
|
| 38 |
-
fallback_font = 'Malgun Gothic'
|
| 39 |
-
elif platform.system() == 'Darwin': # macOS
|
| 40 |
-
korean_font_paths = [
|
| 41 |
-
'/System/Library/Fonts/AppleGothic.ttf',
|
| 42 |
-
'/System/Library/Fonts/Helvetica.ttc',
|
| 43 |
-
]
|
| 44 |
-
fallback_font = 'AppleGothic'
|
| 45 |
-
else: # Linux
|
| 46 |
-
korean_font_paths = [
|
| 47 |
-
'/usr/share/fonts/truetype/nanum/NanumGothic.ttf',
|
| 48 |
-
'/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf',
|
| 49 |
-
]
|
| 50 |
-
fallback_font = 'DejaVu Sans'
|
| 51 |
-
|
| 52 |
-
# ์ฌ์ฉ์ ์ ์ ํฐํธ ํ์ผ ๊ฒฝ๋ก๋ ์ถ๊ฐ
|
| 53 |
-
user_font = os.path.join(os.getcwd(), "NanumGaRamYeonGgoc.ttf")
|
| 54 |
-
if os.path.exists(user_font):
|
| 55 |
-
korean_font_paths.insert(0, user_font)
|
| 56 |
-
|
| 57 |
-
selected_font_path = None
|
| 58 |
-
selected_font_name = fallback_font
|
| 59 |
-
|
| 60 |
-
# ์ค์ ์กด์ฌํ๋ ํฐํธ ํ์ผ ์ฐพ๊ธฐ
|
| 61 |
-
for font_path in korean_font_paths:
|
| 62 |
-
if os.path.exists(font_path):
|
| 63 |
-
try:
|
| 64 |
-
font_prop = fm.FontProperties(fname=font_path)
|
| 65 |
-
selected_font_name = font_prop.get_name()
|
| 66 |
-
selected_font_path = font_path
|
| 67 |
-
|
| 68 |
-
# ํฐํธ ๋งค๋์ ์ ๊ฐ์ ๋ฑ๋ก
|
| 69 |
-
fm.fontManager.addfont(font_path)
|
| 70 |
break
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
if FONT_PATH and os.path.exists(FONT_PATH):
|
| 102 |
-
font_prop = fm.FontProperties(fname=FONT_PATH)
|
| 103 |
-
return font_prop
|
| 104 |
-
else:
|
| 105 |
-
return fm.FontProperties(family=FONT_NAME)
|
| 106 |
|
| 107 |
def analyze_scores(df):
|
| 108 |
"""๋ฐ์ดํฐํ๋ ์์ ๋ฐ์ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ํ๋ ํจ์"""
|
|
@@ -126,7 +77,7 @@ def analyze_scores(df):
|
|
| 126 |
|
| 127 |
st.subheader(f"๐ '{score_column}' ์ ์ ๋ถํฌ ๋ถ์ ๊ฒฐ๊ณผ")
|
| 128 |
|
| 129 |
-
# 1. ๊ธฐ
|
| 130 |
st.write("#### ๐ ๊ธฐ๋ณธ ํต๊ณ๋")
|
| 131 |
col1, col2, col3, col4 = st.columns(4)
|
| 132 |
with col1:
|
|
@@ -142,66 +93,45 @@ def analyze_scores(df):
|
|
| 142 |
st.write("#### ๐ ์์ธ ํต๊ณ๋")
|
| 143 |
st.dataframe(scores.describe().to_frame().T)
|
| 144 |
|
| 145 |
-
# 2. ๋ถํฌ ์๊ฐํ
|
| 146 |
st.write("#### ๐จ ์ ์ ๋ถํฌ ์๊ฐํ")
|
| 147 |
|
| 148 |
try:
|
| 149 |
-
|
| 150 |
-
korean_font = apply_korean_font_to_plot()
|
| 151 |
-
|
| 152 |
-
# Figure ์์ฑ ๋ฐ ์ค์
|
| 153 |
-
fig, ax = plt.subplots(figsize=(14, 8))
|
| 154 |
-
fig.patch.set_facecolor('white')
|
| 155 |
|
| 156 |
-
# ํ์คํ ๊ทธ๋จ
|
| 157 |
-
|
| 158 |
-
color='skyblue', edgecolor='navy', linewidth=0.8)
|
| 159 |
-
|
| 160 |
-
# KDE ๊ณก์ ์ถ๊ฐ
|
| 161 |
-
try:
|
| 162 |
-
from scipy.stats import gaussian_kde
|
| 163 |
-
kde = gaussian_kde(scores)
|
| 164 |
-
x_range = np.linspace(scores.min(), scores.max(), 200)
|
| 165 |
-
ax.plot(x_range, kde(x_range), 'orange', linewidth=3, label='์ค์ ๋ถํฌ ๊ณก์ ')
|
| 166 |
-
except:
|
| 167 |
-
pass
|
| 168 |
|
| 169 |
# ์ ๊ท๋ถํฌ ๊ณก์ ์ถ๊ฐ
|
| 170 |
mu, std = norm.fit(scores)
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
ax.plot(
|
| 174 |
-
label=f'์ ๊ท๋ถํฌ (ํ๊ท ={mu:.1f}, ํ์คํธ์ฐจ={std:.1f})')
|
| 175 |
|
| 176 |
-
# ํ๊ท ์
|
| 177 |
ax.axvline(mu, color='red', linestyle=':', linewidth=2, alpha=0.8, label=f'ํ๊ท : {mu:.1f}')
|
| 178 |
|
| 179 |
-
# ์ ๋ชฉ๊ณผ ๋ผ๋ฒจ - ํ๊ธ
|
| 180 |
-
ax.set_title(f'{score_column} ์ ์ ๋ถํฌ ๋ถ์',
|
| 181 |
-
ax.set_xlabel('์ ์',
|
| 182 |
-
ax.set_ylabel('๋ฐ๋',
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
legend = ax.legend(prop=korean_font, fontsize=11, loc='upper right')
|
| 186 |
-
legend.get_frame().set_alpha(0.9)
|
| 187 |
-
|
| 188 |
-
# ๊ฒฉ์ ์ถ๊ฐ
|
| 189 |
-
ax.grid(True, alpha=0.3, linestyle='-', linewidth=0.5)
|
| 190 |
|
| 191 |
# ํต๊ณ ์ ๋ณด ๋ฐ์ค
|
| 192 |
stats_text = f'์ํ ์: {len(scores)}\nํ๊ท : {mu:.2f}\nํ์คํธ์ฐจ: {std:.2f}\n์ต์๊ฐ: {scores.min():.1f}\n์ต๋๊ฐ: {scores.max():.1f}'
|
| 193 |
ax.text(0.02, 0.98, stats_text, transform=ax.transAxes,
|
| 194 |
-
|
| 195 |
bbox=dict(boxstyle='round,pad=0.5', facecolor='lightblue', alpha=0.8))
|
| 196 |
|
| 197 |
plt.tight_layout()
|
| 198 |
st.pyplot(fig)
|
| 199 |
|
| 200 |
except Exception as e:
|
| 201 |
-
st.error(f"โ
|
| 202 |
|
| 203 |
# ๋์ฒด ๊ทธ๋ํ (์์ด๋ง ์ฌ์ฉ)
|
| 204 |
-
st.write("**
|
| 205 |
fig2, ax2 = plt.subplots(figsize=(10, 6))
|
| 206 |
ax2.hist(scores, bins=15, alpha=0.7, color='lightcoral', edgecolor='black')
|
| 207 |
ax2.set_title(f'Distribution of {score_column}', fontsize=14)
|
|
@@ -225,30 +155,29 @@ def analyze_scores(df):
|
|
| 225 |
|
| 226 |
with col2:
|
| 227 |
if skewness > 0.5:
|
| 228 |
-
st.success("๐ด **์์ ์๋
|
| 229 |
elif skewness < -0.5:
|
| 230 |
-
st.success("๐ต **์์ ์๋
|
| 231 |
else:
|
| 232 |
-
st.success("๐ข **๋์นญ ๋ถํฌ**: ์ ์๊ฐ ํ๊ท ์ ์ค์ฌ์ผ๋ก ๊ณ ๋ฅด๊ฒ ๋ถํฌ
|
| 233 |
|
| 234 |
except Exception as e:
|
| 235 |
-
st.error(f"์๋ ๊ณ์ฐ
|
| 236 |
|
| 237 |
-
# 4.
|
| 238 |
st.write("#### ๐ ๊ตฌ๊ฐ๋ณ ๋ถํฌ")
|
| 239 |
|
| 240 |
-
# ์ ์ ๊ตฌ๊ฐ ๋๋๊ธฐ
|
| 241 |
-
if scores.max() <= 100: # 100์ ๋ง์ ๊ฐ์
|
| 242 |
-
bins_labels = ['0-60', '61-70', '71-80', '81-90', '91-100']
|
| 243 |
-
bins_edges = [0, 60, 70, 80, 90, 100]
|
| 244 |
-
else:
|
| 245 |
-
# ๋์ ๊ตฌ๊ฐ ์์ฑ
|
| 246 |
-
min_score, max_score = scores.min(), scores.max()
|
| 247 |
-
interval = (max_score - min_score) / 5
|
| 248 |
-
bins_edges = [min_score + i * interval for i in range(6)]
|
| 249 |
-
bins_labels = [f'{bins_edges[i]:.0f}-{bins_edges[i+1]:.0f}' for i in range(5)]
|
| 250 |
-
|
| 251 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
score_counts = pd.cut(scores, bins=bins_edges, labels=bins_labels, include_lowest=True).value_counts().sort_index()
|
| 253 |
score_percentages = (score_counts / len(scores) * 100).round(1)
|
| 254 |
|
|
@@ -260,14 +189,13 @@ def analyze_scores(df):
|
|
| 260 |
st.dataframe(result_df)
|
| 261 |
|
| 262 |
except Exception as e:
|
| 263 |
-
st.warning(f"๊ตฌ๊ฐ ๋ถ์
|
| 264 |
|
| 265 |
def main():
|
| 266 |
st.set_page_config(
|
| 267 |
page_title="ํ์ ์ ์ ๋ถ์ ๋๊ตฌ",
|
| 268 |
page_icon="๐",
|
| 269 |
-
layout="wide"
|
| 270 |
-
initial_sidebar_state="expanded"
|
| 271 |
)
|
| 272 |
|
| 273 |
# ์ ๋ชฉ
|
|
@@ -276,25 +204,19 @@ def main():
|
|
| 276 |
|
| 277 |
# ํฐํธ ์ ๋ณด ํ์
|
| 278 |
with st.expander("๐ง ํฐํธ ์ค์ ์ ๋ณด"):
|
| 279 |
-
st.write(f"**ํ์ฌ ํฐํธ**: {
|
| 280 |
st.write(f"**ํฐํธ ๊ฒฝ๋ก**: {FONT_PATH if FONT_PATH else '์์คํ
๊ธฐ๋ณธ'}")
|
| 281 |
|
| 282 |
-
# ํฐํธ ํ
์คํธ
|
| 283 |
if st.button("ํฐํธ ํ
์คํธ"):
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
test_ax.set_ylim(0, 1)
|
| 293 |
-
test_ax.axis('off')
|
| 294 |
-
st.pyplot(test_fig)
|
| 295 |
-
plt.close(test_fig)
|
| 296 |
-
except Exception as e:
|
| 297 |
-
st.error(f"ํฐํธ ํ
์คํธ ์คํจ: {e}")
|
| 298 |
|
| 299 |
st.markdown("---")
|
| 300 |
|
|
|
|
| 10 |
import warnings
|
| 11 |
warnings.filterwarnings('ignore')
|
| 12 |
|
| 13 |
+
# ์ฌํํ ํ๊ธ ํฐํธ ์ค์ - ์ฑ ์์์ ํ๋ฒ๋ง ์คํ
|
| 14 |
+
def setup_korean_font():
|
| 15 |
+
"""ํ๊ธ ํฐํธ๋ฅผ ๊ฐ๋จํ๊ฒ ์ค์ ํ๋ ํจ์"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
try:
|
| 17 |
+
# 1. ์ฌ์ฉ์ ํฐํธ ํ์ผ ํ์ธ
|
| 18 |
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
| 19 |
+
possible_fonts = ["NanumGaRamYeonGgoc.ttf", "NanumGothic.ttf", "malgun.ttf"]
|
| 20 |
+
|
| 21 |
+
font_path = None
|
| 22 |
+
for font_file in possible_fonts:
|
| 23 |
+
candidate = os.path.join(script_dir, font_file)
|
| 24 |
+
if os.path.exists(candidate):
|
| 25 |
+
font_path = candidate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
break
|
| 27 |
+
|
| 28 |
+
# 2. ํฐํธ ์ ์ฉ
|
| 29 |
+
if font_path:
|
| 30 |
+
# ํฐํธ ํ์ผ์ด ์์ผ๋ฉด ์ง์ ์ฌ์ฉ
|
| 31 |
+
plt.rcParams['font.family'] = fm.FontProperties(fname=font_path).get_name()
|
| 32 |
+
st.sidebar.success(f"ํฐํธ ๋ก๋ฉ ์ฑ๊ณต: {os.path.basename(font_path)}")
|
| 33 |
+
else:
|
| 34 |
+
# ์์คํ
๊ธฐ๋ณธ ํฐํธ ์ฌ์ฉ
|
| 35 |
+
if platform.system() == 'Windows':
|
| 36 |
+
plt.rcParams['font.family'] = 'Malgun Gothic'
|
| 37 |
+
elif platform.system() == 'Darwin': # macOS
|
| 38 |
+
plt.rcParams['font.family'] = 'AppleGothic'
|
| 39 |
+
else: # Linux
|
| 40 |
+
plt.rcParams['font.family'] = 'DejaVu Sans'
|
| 41 |
+
|
| 42 |
+
st.sidebar.info(f"์์คํ
๊ธฐ๋ณธ ํฐํธ ์ฌ์ฉ: {plt.rcParams['font.family']}")
|
| 43 |
+
|
| 44 |
+
# ๋ง์ด๋์ค ๊ธฐํธ ๊นจ์ง ๋ฐฉ์ง
|
| 45 |
+
plt.rcParams['axes.unicode_minus'] = False
|
| 46 |
+
|
| 47 |
+
return font_path
|
| 48 |
+
|
| 49 |
+
except Exception as e:
|
| 50 |
+
st.sidebar.warning(f"ํฐํธ ์ค์ ์ค๋ฅ: {e}")
|
| 51 |
+
plt.rcParams['font.family'] = 'DejaVu Sans'
|
| 52 |
+
plt.rcParams['axes.unicode_minus'] = False
|
| 53 |
+
return None
|
| 54 |
|
| 55 |
+
# ์ฑ ์์์ ํฐํธ ์ค์
|
| 56 |
+
FONT_PATH = setup_korean_font()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
def analyze_scores(df):
|
| 59 |
"""๋ฐ์ดํฐํ๋ ์์ ๋ฐ์ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ํ๋ ํจ์"""
|
|
|
|
| 77 |
|
| 78 |
st.subheader(f"๐ '{score_column}' ์ ์ ๋ถํฌ ๋ถ์ ๊ฒฐ๊ณผ")
|
| 79 |
|
| 80 |
+
# 1. ๊ธฐ๋ณธ ํต๊ณ๋
|
| 81 |
st.write("#### ๐ ๊ธฐ๋ณธ ํต๊ณ๋")
|
| 82 |
col1, col2, col3, col4 = st.columns(4)
|
| 83 |
with col1:
|
|
|
|
| 93 |
st.write("#### ๐ ์์ธ ํต๊ณ๋")
|
| 94 |
st.dataframe(scores.describe().to_frame().T)
|
| 95 |
|
| 96 |
+
# 2. ๋ถํฌ ์๊ฐํ
|
| 97 |
st.write("#### ๐จ ์ ์ ๋ถํฌ ์๊ฐํ")
|
| 98 |
|
| 99 |
try:
|
| 100 |
+
fig, ax = plt.subplots(figsize=(12, 7))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
# ํ์คํ ๊ทธ๋จ๊ณผ KDE ๊ณก์
|
| 103 |
+
sns.histplot(scores, kde=True, stat='density', alpha=0.7, ax=ax, color='skyblue')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# ์ ๊ท๋ถํฌ ๊ณก์ ์ถ๊ฐ
|
| 106 |
mu, std = norm.fit(scores)
|
| 107 |
+
x = np.linspace(scores.min(), scores.max(), 100)
|
| 108 |
+
y = norm.pdf(x, mu, std)
|
| 109 |
+
ax.plot(x, y, 'r-', linewidth=2, label=f'์ ๊ท๋ถํฌ (ฮผ={mu:.1f}, ฯ={std:.1f})')
|
|
|
|
| 110 |
|
| 111 |
+
# ํ๊ท ์
|
| 112 |
ax.axvline(mu, color='red', linestyle=':', linewidth=2, alpha=0.8, label=f'ํ๊ท : {mu:.1f}')
|
| 113 |
|
| 114 |
+
# ์ ๋ชฉ๊ณผ ๋ผ๋ฒจ - ํ๊ธ์ด ์ ๋ณด์ด๋๋ก ์ค์
|
| 115 |
+
ax.set_title(f'{score_column} ์ ์ ๋ถํฌ ๋ถ์', fontsize=16, pad=20)
|
| 116 |
+
ax.set_xlabel('์ ์', fontsize=12)
|
| 117 |
+
ax.set_ylabel('๋ฐ๋', fontsize=12)
|
| 118 |
+
ax.legend(fontsize=10)
|
| 119 |
+
ax.grid(True, alpha=0.3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
# ํต๊ณ ์ ๋ณด ๋ฐ์ค
|
| 122 |
stats_text = f'์ํ ์: {len(scores)}\nํ๊ท : {mu:.2f}\nํ์คํธ์ฐจ: {std:.2f}\n์ต์๊ฐ: {scores.min():.1f}\n์ต๋๊ฐ: {scores.max():.1f}'
|
| 123 |
ax.text(0.02, 0.98, stats_text, transform=ax.transAxes,
|
| 124 |
+
fontsize=10, verticalalignment='top',
|
| 125 |
bbox=dict(boxstyle='round,pad=0.5', facecolor='lightblue', alpha=0.8))
|
| 126 |
|
| 127 |
plt.tight_layout()
|
| 128 |
st.pyplot(fig)
|
| 129 |
|
| 130 |
except Exception as e:
|
| 131 |
+
st.error(f"โ ๊ทธ๋ํ ์์ฑ ์ค๋ฅ: {e}")
|
| 132 |
|
| 133 |
# ๋์ฒด ๊ทธ๋ํ (์์ด๋ง ์ฌ์ฉ)
|
| 134 |
+
st.write("**Simple Chart (English):**")
|
| 135 |
fig2, ax2 = plt.subplots(figsize=(10, 6))
|
| 136 |
ax2.hist(scores, bins=15, alpha=0.7, color='lightcoral', edgecolor='black')
|
| 137 |
ax2.set_title(f'Distribution of {score_column}', fontsize=14)
|
|
|
|
| 155 |
|
| 156 |
with col2:
|
| 157 |
if skewness > 0.5:
|
| 158 |
+
st.success("๐ด **์์ ์๋**: ๋๋ถ๋ถ ํ์์ด ๋ฎ์ ์ ์๋์ ๋ถํฌ, ์์์ ๊ณ ๋์ ์ ์กด์ฌ")
|
| 159 |
elif skewness < -0.5:
|
| 160 |
+
st.success("๐ต **์์ ์๋**: ๋๋ถ๋ถ ํ์์ด ๋์ ์ ์๋์ ๋ถํฌ, ์์์ ์ ๋์ ์ ์กด์ฌ")
|
| 161 |
else:
|
| 162 |
+
st.success("๐ข **๋์นญ ๋ถํฌ**: ์ ์๊ฐ ํ๊ท ์ ์ค์ฌ์ผ๋ก ๊ณ ๋ฅด๊ฒ ๋ถํฌ")
|
| 163 |
|
| 164 |
except Exception as e:
|
| 165 |
+
st.error(f"์๋ ๊ณ์ฐ ์ค๋ฅ: {e}")
|
| 166 |
|
| 167 |
+
# 4. ๊ตฌ๊ฐ๋ณ ๋ถํฌ
|
| 168 |
st.write("#### ๐ ๊ตฌ๊ฐ๋ณ ๋ถํฌ")
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
try:
|
| 171 |
+
if scores.max() <= 100: # 100์ ๋ง์ ๊ฐ์
|
| 172 |
+
bins_labels = ['0-60', '61-70', '71-80', '81-90', '91-100']
|
| 173 |
+
bins_edges = [0, 60, 70, 80, 90, 100]
|
| 174 |
+
else:
|
| 175 |
+
# ๋์ ๊ตฌ๊ฐ ์์ฑ
|
| 176 |
+
min_score, max_score = scores.min(), scores.max()
|
| 177 |
+
interval = (max_score - min_score) / 5
|
| 178 |
+
bins_edges = [min_score + i * interval for i in range(6)]
|
| 179 |
+
bins_labels = [f'{bins_edges[i]:.0f}-{bins_edges[i+1]:.0f}' for i in range(5)]
|
| 180 |
+
|
| 181 |
score_counts = pd.cut(scores, bins=bins_edges, labels=bins_labels, include_lowest=True).value_counts().sort_index()
|
| 182 |
score_percentages = (score_counts / len(scores) * 100).round(1)
|
| 183 |
|
|
|
|
| 189 |
st.dataframe(result_df)
|
| 190 |
|
| 191 |
except Exception as e:
|
| 192 |
+
st.warning(f"๊ตฌ๊ฐ ๋ถ์ ์ค๋ฅ: {e}")
|
| 193 |
|
| 194 |
def main():
|
| 195 |
st.set_page_config(
|
| 196 |
page_title="ํ์ ์ ์ ๋ถ์ ๋๊ตฌ",
|
| 197 |
page_icon="๐",
|
| 198 |
+
layout="wide"
|
|
|
|
| 199 |
)
|
| 200 |
|
| 201 |
# ์ ๋ชฉ
|
|
|
|
| 204 |
|
| 205 |
# ํฐํธ ์ ๋ณด ํ์
|
| 206 |
with st.expander("๐ง ํฐํธ ์ค์ ์ ๋ณด"):
|
| 207 |
+
st.write(f"**ํ์ฌ ํฐํธ**: {plt.rcParams['font.family']}")
|
| 208 |
st.write(f"**ํฐํธ ๊ฒฝ๋ก**: {FONT_PATH if FONT_PATH else '์์คํ
๊ธฐ๋ณธ'}")
|
| 209 |
|
| 210 |
+
# ๊ฐ๋จํ ํฐํธ ํ
์คํธ
|
| 211 |
if st.button("ํฐํธ ํ
์คํธ"):
|
| 212 |
+
fig, ax = plt.subplots(figsize=(6, 2))
|
| 213 |
+
ax.text(0.5, 0.5, 'ํ๊ธ ํฐํธ ํ
์คํธ: ์ ์ ๋ถํฌ ๋ถ์',
|
| 214 |
+
ha='center', va='center', fontsize=14)
|
| 215 |
+
ax.set_xlim(0, 1)
|
| 216 |
+
ax.set_ylim(0, 1)
|
| 217 |
+
ax.axis('off')
|
| 218 |
+
st.pyplot(fig)
|
| 219 |
+
plt.close(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
st.markdown("---")
|
| 222 |
|