शुरू करेंमुफ़्त में शुरू करें

Overfitting से बचने के लिए smoothing parameters का उपयोग

Smoothing parameter, मॉडल fit को optimize करने के लिए likelihood और wiggliness के बीच संतुलन बनाता है. यहाँ, आप smoothing parameters की जाँच करेंगे और अलग‑अलग fixed smoothing parameters के साथ मॉडल फिट करेंगे.

यह अभ्यास पाठ्यक्रम का हिस्सा है

R में Generalized Additive Models (GAMs) के साथ नॉनलाइनियर मॉडलिंग

पाठ्यक्रम देखें

अभ्यास निर्देश

  • दिए गए gam_mod मॉडल से sp मान निकालकर smoothing parameter (\(\lambda\)) का मान देखें.
  • mcycle डेटा पर दो मॉडल फिट करें, जहाँ accel, times का एक smooth फंक्शन हो और smoothing parameter हो:
    • 0.1
    • 0.0001
  • दोनों मॉडलों को visualize करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

library(mgcv)
# Extract the smoothing parameter
gam_mod <- gam(accel ~ s(times), data = mcycle, method = "REML")
___

# Fix the smoothing parameter at 0.1
gam_mod_s1 <- gam(accel ~ s(times), data = mcycle, sp = ___)

# Fix the smoothing parameter at 0.0001
gam_mod_s2 <- gam(___)

# Plot both models
par(mfrow = c(2, 1))
plot(gam_mod_s1, residuals = TRUE, pch = 1)
plot(gam_mod_s2, residuals = TRUE, pch = 1)
कोड संपादित करें और चलाएँ