2025 내일배움캠프 QAQC_2기

2025 내일배움캠프 QAQC_2기 본캠프 36일차

mingdoremi 2025. 7. 2. 21:51

안녕하세요! 오늘은 본캠프 36일차입니다!

 

오늘의 베이직 문제!

1번. 치료 전후 혈압 비교

import pandas as pd
from scipy import stats

# 데이터: 같은 환자의 치료 전후 혈압
before = [150, 155, 160, 145, 158, 162, 148, 152]
after = [140, 145, 155, 138, 150, 155, 142, 145]

# 정규성 검정 후 적절한 검정 수행
# 빈칸: 어떤 검정을 사용해야 할까요?
statistic, p_value = stats._________(before, after)

print(f"검정통계량: {statistic:.4f}")
print(f"p-value: {p_value:.4f}")

import pandas as pd
from scipy import stats

# 데이터: 같은 환자의 치료 전후 혈압
before = [150, 155, 160, 145, 158, 162, 148, 152]
after = [140, 145, 155, 138, 150, 155, 142, 145]

statistic, p_value = stats.ttest_rel(before, after)

print(f"검정통계량: {statistic:.4f}")
print(f"p-value: {p_value:.4f}")

2번. 세 가지 다이어트 프로그램 비교

import pandas as pd
from scipy import stats

# 데이터: 각 프로그램별 체중 감량량(kg)
program_A = [3.2, 2.8, 4.1, 3.5, 2.9, 3.8, 4.2]
program_B = [2.1, 1.8, 2.5, 2.3, 1.9, 2.7, 2.2]
program_C = [4.5, 5.1, 4.8, 5.3, 4.9, 5.2, 4.7]

# 빈칸: 세 그룹을 비교하는 적절한 검정은?
f_stat, p_value = stats._________(program_A, program_B, program_C)

print(f"F-통계량: {f_stat:.4f}")
print(f"p-value: {p_value:.4f}")

import pandas as pd
from scipy import stats

# 데이터: 각 프로그램별 체중 감량량(kg)
program_A = [3.2, 2.8, 4.1, 3.5, 2.9, 3.8, 4.2]
program_B = [2.1, 1.8, 2.5, 2.3, 1.9, 2.7, 2.2]
program_C = [4.5, 5.1, 4.8, 5.3, 4.9, 5.2, 4.7]

f_stat, p_value = stats.f_oneway(program_A, program_B, program_C)

print(f"F-통계량: {f_stat:.4f}")
print(f"p-value: {p_value:.4f}")

3번. 성별에 따른 연봉 차이

import pandas as pd
from scipy import stats

# 데이터프레임
df = pd.DataFrame({
'gender': ['M', 'F', 'M', 'F', 'M', 'F', 'M', 'F', 'M', 'F'],
'salary': [5500, 5200, 6000, 5300, 5800, 5100, 6200, 5400, 5700, 5250]
})

# 남성과 여성 그룹 분리
male_salary = df[df['gender'] == 'M']['salary']
female_salary = df[df['gender'] == 'F']['salary']

# 빈칸: 두 독립된 그룹의 평균을 비교하는 검정은?
t_stat, p_value = stats._________(male_salary, female_salary)

print(f"t-통계량: {t_stat:.4f}")
print(f"p-value: {p_value:.4f}")

 

import pandas as pd
from scipy import stats

# 데이터프레임
df = pd.DataFrame({
    'gender': ['M', 'F', 'M', 'F', 'M', 'F', 'M', 'F', 'M', 'F'],
    'salary': [5500, 5200, 6000, 5300, 5800, 5100, 6200, 5400, 5700, 5250]
})

# 남성과 여성 그룹 분리
male_salary = df[df['gender'] == 'M']['salary']
female_salary = df[df['gender'] == 'F']['salary']

t_stat, p_value = stats.ttest_ind(male_salary, female_salary)

print(f"t-통계량: {t_stat:.4f}")
print(f"p-value: {p_value:.4f}")

4번. 공부 시간과 시험 점수의 관계

import pandas as pd
from scipy import stats

# 데이터: 공부 시간(시간)과 시험 점수
study_hours = [2, 3, 1, 4, 5, 2, 3, 4, 1, 5]
test_scores = [65, 75, 55, 85, 90, 60, 78, 82, 58, 88]

# 빈칸: 두 연속형 변수 간의 관계를 분석하는 방법은?
correlation, p_value = stats._________(study_hours, test_scores)

print(f"상관계수: {correlation:.4f}")
print(f"p-value: {p_value:.4f}")

import pandas as pd
from scipy import stats

# 데이터: 공부 시간(시간)과 시험 점수
study_hours = [2, 3, 1, 4, 5, 2, 3, 4, 1, 5]
test_scores = [65, 75, 55, 85, 90, 60, 78, 82, 58, 88]

correlation, p_value = stats.pearsonr(study_hours, test_scores)

print(f"상관계수: {correlation:.4f}")
print(f"p-value: {p_value:.4f}")

5번. 흡연과 폐암의 관련성

import pandas as pd
from scipy.stats import chi2_contingency

# 교차표 데이터
# 행: 흡연 여부, 열: 폐암 여부
contingency_table = [[30, 10], # 흡연자: 폐암 있음 30명, 없음 10명
[5, 45]] # 비흡연자: 폐암 있음 5명, 없음 45명

# 빈칸: 범주형 변수 간의 독립성을 검정하는 방법은?
chi2, p_value, dof, expected = ___________(contingency_table)

print(f"카이제곱 통계량: {chi2:.4f}")
print(f"p-value: {p_value:.4f}")

import pandas as pd
from scipy.stats import chi2_contingency

# 교차표 데이터
# 행: 흡연 여부, 열: 폐암 여부
contingency_table = [[30, 10],  # 흡연자: 폐암 있음 30명, 없음 10명
                     [5, 45]]   # 비흡연자: 폐암 있음 5명, 없음 45명

chi2, p_value, dof, expected = chi2_contingency(contingency_table)

print(f"카이제곱 통계량: {chi2:.4f}")
print(f"p-value: {p_value:.4f}")

 

그리고 오늘은 하루종일 개인과제를 풀었습니다....

 

엄청 어렵네요.... 😭

분명 비전공자 기준으로 2시간에서 더 걸린다고 되어있는데 하루종일 풀고 있어요....큐큐

10시가 넘었는데 아직 못 끝내서 내일 오전에 빨리 풀어서 끝내야겠어요!!!

 

오늘도 수고하셨습니다!