평균 발생률 계산하기
예측 변수 인사이트 그래프 테이블에서 가장 중요한 열은 타깃 발생률 열입니다. 이 열은 각 그룹의 평균 타깃 값을 보여줍니다.
이 연습은 강의의 일부입니다
Python으로 배우는 예측 분석 입문
연습 안내
target과income변수만 포함하는 DataFramebasetable_income을 생성하세요.- 이 DataFrame을
income으로 그룹화하세요. - 각
income그룹에 대해 평균 타깃 발생률을 계산하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Select the income and target columns
basetable_income = basetable[["____","____"]]
# Group basetable_income by income
groups = basetable_income.____("____")
# Calculate the target incidence and print the result
incidence = groups["____"].agg(Incidence = '____').reset_index()
print(incidence)