JUNGU commited on
Commit
f988369
Β·
verified Β·
1 Parent(s): 76e68f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -23
app.py CHANGED
@@ -357,34 +357,49 @@ def perform_analysis():
357
  if st.button("μ •κ·œμ„± κ²€μ • μˆ˜ν–‰"):
358
  check_normality(st.session_state.filtered_data, normality_column)
359
 
360
- # T-κ²€μ •
361
- st.write("T-κ²€μ •")
362
- test_type = st.radio("T-κ²€μ • μœ ν˜• 선택:", ["독립 ν‘œλ³Έ", "λŒ€μ‘ ν‘œλ³Έ", "단일 ν‘œλ³Έ"])
363
-
364
  if test_type == "독립 ν‘œλ³Έ":
365
- # μŠ¬λΌμ΄μ„œμ—μ„œ μ„ νƒλœ λ²”μ£Όν˜• λ³€μˆ˜ λͺ©λ‘ 생성
366
- # active_slicers = [col for col in st.session_state.slicers.keys() if st.session_state.slicers[col]]
367
- active_slicers = list(st.session_state.slicers.keys())
 
 
368
 
369
- group_column = st.selectbox(
370
- "κ·Έλ£Ή ꡬ뢄을 μœ„ν•œ μ—΄ 선택:",
371
- options=active_slicers + [col for col in st.session_state.categorical_columns if col not in active_slicers]
372
- )
373
-
374
- value_column = st.selectbox("비ꡐ할 값이 μžˆλŠ” μ—΄ 선택:", st.session_state.numeric_columns)
375
 
376
-
377
- if st.button("독립 ν‘œλ³Έ T-κ²€μ • μˆ˜ν–‰"):
378
- # μ„ νƒλœ 그룹의 μœ λ‹ˆν¬ κ°’ 확인
379
- if group_column in st.session_state.slicers:
380
- unique_groups = st.session_state.slicers[group_column]
381
- else:
382
- unique_groups = st.session_state.filtered_data[group_column].unique()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
- if len(unique_groups) == 2:
385
- perform_independent_ttest(st.session_state.filtered_data, group_column, value_column)
386
  else:
387
- st.error(f"μ„ νƒλœ κ·Έλ£Ή λ³€μˆ˜ '{group_column}'μ—λŠ” μ •ν™•νžˆ 두 개의 그룹이 μžˆμ–΄μ•Ό ν•©λ‹ˆλ‹€. ν˜„μž¬ κ·Έλ£Ή 수: {len(unique_groups)}")
 
 
388
 
389
 
390
  elif test_type == "λŒ€μ‘ ν‘œλ³Έ":
 
357
  if st.button("μ •κ·œμ„± κ²€μ • μˆ˜ν–‰"):
358
  check_normality(st.session_state.filtered_data, normality_column)
359
 
 
 
 
 
360
  if test_type == "독립 ν‘œλ³Έ":
361
+ # ν™œμ„±ν™”λœ μŠ¬λΌμ΄μ„œμ™€ κ·Έ μ„ νƒλœ 값듀을 확인
362
+ active_slicers = {}
363
+ for col, values in st.session_state.slicers.items():
364
+ if values: # μ„ νƒλœ 값이 μžˆλŠ” 경우만 포함
365
+ active_slicers[col] = values
366
 
367
+ if active_slicers:
368
+ group_column = st.selectbox("κ·Έλ£Ή ꡬ뢄을 μœ„ν•œ μ—΄ 선택:", options=list(active_slicers.keys()))
 
 
 
 
369
 
370
+ # μ„ νƒλœ κ·Έλ£Ή μ—΄μ˜ κ°’λ“€ μ€‘μ—μ„œ 두 κ·Έλ£Ή 선택
371
+ available_groups = active_slicers[group_column]
372
+ group1 = st.selectbox("첫 번째 κ·Έλ£Ή 선택:", options=available_groups, key="group1")
373
+ group2 = st.selectbox("두 번째 κ·Έλ£Ή 선택:",
374
+ options=[g for g in available_groups if g != group1],
375
+ key="group2")
376
+ else:
377
+ st.warning("ν™œμ„±ν™”λœ μŠ¬λΌμ΄μ„œκ°€ μ—†μŠ΅λ‹ˆλ‹€. λ¨Όμ € μŠ¬λΌμ΄μ„œμ—μ„œ 그룹을 μ„ νƒν•΄μ£Όμ„Έμš”.")
378
+ group_column = None
379
+ group1 = None
380
+ group2 = None
381
+
382
+ value_column = st.selectbox("비ꡐ할 값이 μžˆλŠ” μ—΄ 선택:", st.session_state.numeric_columns)
383
+
384
+ if st.button("독립 ν‘œλ³Έ T-κ²€μ • μˆ˜ν–‰"):
385
+ if group_column and group1 and group2:
386
+ # μ„ νƒλœ 두 그룹으둜 데이터 필터링
387
+ group1_data = st.session_state.filtered_data[st.session_state.filtered_data[group_column] == group1]
388
+ group2_data = st.session_state.filtered_data[st.session_state.filtered_data[group_column] == group2]
389
+
390
+ # T-κ²€μ • μˆ˜ν–‰
391
+ t_stat, p_value = stats.ttest_ind(group1_data[value_column], group2_data[value_column])
392
+
393
+ st.write(f"독립 ν‘œλ³Έ T-κ²€μ • κ²°κ³Ό ({group_column}: {group1} vs {group2}, {value_column} 비ꡐ):")
394
+ st.write(f"t-ν†΅κ³„λŸ‰: {t_stat:.4f}")
395
+ st.write(f"p-value: {p_value:.4f}")
396
 
397
+ if p_value < 0.05:
398
+ st.write(f"{group1}κ³Ό {group2} 간에 ν†΅κ³„μ μœΌλ‘œ μœ μ˜ν•œ 차이가 μžˆμŠ΅λ‹ˆλ‹€.")
399
  else:
400
+ st.write(f"{group1}κ³Ό {group2} 간에 ν†΅κ³„μ μœΌλ‘œ μœ μ˜ν•œ 차이가 μ—†μŠ΅λ‹ˆλ‹€.")
401
+ else:
402
+ st.error("κ·Έλ£Ή 선택이 μ™„λ£Œλ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.")
403
 
404
 
405
  elif test_type == "λŒ€μ‘ ν‘œλ³Έ":