एक प्रारंभिक मॉडल
आपको एक डेटासेट दिया गया है जिसमें अलग-अलग दूरियों पर दो पिंडों के बीच गुरुत्वाकर्षण बल के माप हैं, और आपसे चुनौती है कि किसी दी गई दूरी पर बल का अनुमान लगाने के लिए एक सरल मॉडल बनाएँ. शुरुआत में, आप simple linear regression तक ही सीमित रहना चाहते हैं. डेटा में distance और force की 120 जोड़ियाँ हैं, और यह आपके लिए newton के रूप में लोड है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
R में Feature Engineering
अभ्यास निर्देश
- base
Rके linear model फंक्शन का उपयोग करते हुएnewtonडेटा के लिए एक linear model बनाएँ और उसेlr_forceको असाइन करें. - prediction मानों को मूल
newtonडेटा से bind करके नया डेटा फ़्रेमdfबनाएँ. ggplot()का उपयोग करकेforceबनामdistanceका एक scatterplot बनाएँ.- fitted values के साथ scatterplot में एक regression line जोड़ें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Build a linear model for the newton the data and assign it to lr_force
lr_force <- ___(force ~ distance, data = ___)
# Create a new data frame by binding the prediction values to the original data
df <- newton %>% ___(lr_pred = predict(lr_force))
# Generate a scatterplot of force vs. distance
df %>%
ggplot(aes(x = distance, y = force)) +
geom____() +
# Add a regression line with the fitted values
geom_line(aes(y = ___), color = "blue", lwd = .75) +
ggtitle("Linear regression of force vs. distance") +
theme_classic()