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

अपने मॉडलों के coefficients को टाइडी करें

इस अभ्यास में आप list column workflow और broom के tidy() फंक्शन का उपयोग करके, अपने बनाए गए 77 मॉडलों के coefficients निकालेंगे और उनका अन्वेषण करेंगे.

याद रखिए, gap_models डेटा फ्रेम में 77 देशों के लिए year से life expectancy की भविष्यवाणी करने वाला मॉडल है.

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

Tidyverse में मशीन लर्निंग

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

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

  • tidy() का उपयोग करके gap_models डेटा फ्रेम में हर मॉडल के लिए coefficient statistics वाली एक कॉलम (coef) जोड़ें और उसे model_coef_nested नाम से सेव करें.
  • इस डेटा फ्रेम को सरल बनाने के लिए unnest() का उपयोग करें, ताकि ये coefficients आपके डेटा फ्रेम में निकल आएँ.
  • अपने 77 मॉडलों में year फीचर के coefficient estimates को उनके मानों का histogram प्लॉट करके एक्सप्लोर करें.

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

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

# Extract the coefficient statistics of each model into nested data frames
model_coef_nested <- gap_models %>% 
    mutate(coef = map(model, ~___(.x)))
    
# Simplify the coef data frames for each model    
model_coef <- model_coef_nested %>%
    unnest(___)

# Plot a histogram of the coefficient estimates for year         
model_coef %>% 
  filter(term == "___") %>% 
  ggplot(aes(x = ___)) +
  geom_histogram()
कोड संपादित करें और चलाएँ