カテゴリ変数を使ったモデリング
この演習では、flowers データに対して線形モデルを当てはめ、Time と Intensity から Flowers を予測します。
前の演習で作成したモデルの formula fmla と、モデル行列 mmat は引き続き利用できます。
この演習はコースの一部です
R による Supervised Learning:回帰
演習の手順
fmlaとlmを使って、IntensityとTimeからFlowersを予測する線形モデルを学習し、変数flower_modelに代入します。summary()を使って、mmatの構造を確認しましょう。summary()を使ってflower_modelを確認します。変数はmmatで見たものと一致していますか?flower_modelを使って花の数を予測し、予測値をflowersの列predictionsとして追加します。- 予測値と実測の散布図を描きます(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")