เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การสร้างโมเดลด้วย input ประเภท categorical

ในแบบฝึกหัดนี้ จะฝึกสร้างโมเดลเชิงเส้นกับข้อมูล flowers เพื่อทำนาย Flowers จาก Time และ Intensity

สูตรโมเดล fmla ที่สร้างไว้ในแบบฝึกหัดก่อนหน้ายังคงพร้อมใช้งาน เช่นเดียวกับ model matrix mmat

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Supervised Learning ใน R: การถดถอย

ดูคอร์ส

คำแนะนำการฝึกหัด

  • ใช้ fmla และ lm เพื่อ train โมเดลเชิงเส้นที่ทำนาย Flowers จาก Intensity และ Time แล้วกำหนดโมเดลให้กับตัวแปร 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") 
แก้ไขและรันโค้ด