Correlation की जाँच
आप यह समझना चाहते हैं कि Las Vegas और Houston में किराए की कीमतें सहसंबद्ध हैं या नहीं. अगर Las Vegas में कीमतें बढ़ती दिखें, तो क्या यह मानना उचित है कि Houston में भी बढ़ेंगी? Las Vegas (lasvegas_rents) और Houston (houston_rents) के लिए किराए के NumPy array लोड किए गए हैं, साथ ही प्रत्येक माप से जुड़ी dates भी उपलब्ध हैं.
पैकेज pandas pd के रूप में, NumPy np के रूप में, Matplotlib plt के रूप में, और SciPy का stats पैकेज आपके लिए पहले से लोड है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में अनुमान का आधार
अभ्यास निर्देश
datesको x-axis पर रखते हुए,houston_rentsऔरlasvegas_rentsके लिए दो लाइनों वाला एक line graph बनाएँ.- Pearson correlation coefficient और उससे जुड़ी p-value की गणना करें.
- यह निर्धारित करें और एक Boolean प्रिंट करें जो बताए कि p-value 5% स्तर पर significant है या नहीं.
- R-squared प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create a line graph showing the rents for both San Francisco and Las Vegas
____(____, ____, label='Houston')
____(____, ____, label='Las Vegas')
plt.show()
# Compute the Pearson correlation coefficient R, as well as the p-value
r, p_value = ____(____, ____)
# Print if the p-value is less than alpha = 5%
____
# Print out R-squared
____