실업률 모델을 그래프로 평가하기
이 연습 문제에서는 앞 장에서 unemployment 데이터에 적합한 unemployment_model을 그래프로 평가해 보겠습니다. 이 모델은 male_unemployment로부터 female_unemployment를 예측합니다.
먼저 모델의 예측값을 실제 female_unemployment와 비교하여 산점도를 그립니다. 명령은 다음과 같은 형태예요.
ggplot(dframe, aes(x = pred, y = outcome)) +
geom_point() +
geom_abline()
그다음 잔차를 계산합니다:
residuals <- actual outcome - predicted outcome
그리고 예측값 대비 잔차를 그립니다. 잔차 그래프는 약간 다른 형태를 취합니다. 직선 $x=y$와 비교하는 대신 수평선 \(y=0\)(geom_hline())과 비교합니다. 필요한 명령은 제공됩니다.
데이터 프레임 unemployment와 모델 unemployment_model은 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
R로 하는 Supervised Learning: 회귀
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# unemployment and unemployment_model are available
summary(unemployment)
summary(unemployment_model)
# Make predictions from the model
unemployment$predictions <- ___
# Fill in the blanks to plot predictions (on x-axis) versus the female_unemployment rates
___(___, aes(x = ___, y = ___)) +
geom_point() +
geom_abline()