Mô hình hóa với biến đầu vào phân loại
Trong bài này, bạn sẽ khớp một mô hình tuyến tính cho dữ liệu flowers để dự đoán Flowers theo Time và Intensity.
Công thức mô hình fmla mà bạn đã tạo ở bài trước vẫn còn sẵn, cũng như ma trận mô hình mmat.
Bài tập này là một phần của khóa học
Học có giám sát với R: Hồi quy
Hướng dẫn bài tập
- Dùng
fmlavàlmđể huấn luyện mô hình tuyến tính dự đoánFlowerstừIntensityvàTime. Gán mô hình vào biếnflower_model. - Dùng
summary()để xem lại cấu trúc củammat. - Dùng
summary()để xem xétflower_model. Các biến có khớp với những gì bạn thấy trongmmatkhông? - Dùng
flower_modelđể dự đoán số bông hoa. Thêm các dự đoán vàoflowersdưới dạng cộtpredictions. - Điền vào chỗ trống để vẽ biểu đồ dự đoán so với giá trị thực tế (dự đoán trên trục x).
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
# 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")