시작하기무료로 시작하기

범주형 입력으로 모델링하기

이번 연습에서는 flowers 데이터에 선형 모델을 적합해 TimeIntensity를 사용하여 Flowers를 예측해 보겠습니다.

이전 연습에서 만든 모델 공식 fmla와 모델 행렬 mmat은 그대로 사용할 수 있습니다.

이 연습은 강의의 일부입니다

R로 하는 Supervised Learning: 회귀

강의 보기

연습 안내

  • fmlalm을 사용해 IntensityTime으로부터 Flowers를 예측하는 선형 모델을 학습하세요. 모델을 변수 flower_model에 할당하세요.
  • summary()mmat의 구조를 다시 확인하세요.
  • summary()flower_model을 살펴보세요. 변수들이 mmat에서 본 것과 일치하나요?
  • flower_model을 사용해 꽃의 개수를 예측하세요. 예측 값을 flowerspredictions 열로 추가하세요.
  • 빈칸을 채워 예측값 대비 실제 꽃 개수를 그리세요(x축에는 예측값).

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# flowers is available
str(flowers)

# fmla is available
fmla

# Fit a model to predict Flowers from Intensity and Time : flower_model
flower_model <- ___

# Use summary on mmat to remind yourself of its structure
___

# Use summary to examine flower_model 
___

# Predict the number of flowers on each plant
flowers$predictions <- ___

# Plot predictions vs actual flowers (predictions on x-axis)
ggplot(___, aes(x = ___, y = ___)) + 
  geom_point() +
  geom_abline(color = "blue") 
코드 편집 및 실행