np.corrcoef() से Correlation
Correlation बताता है कि numbers के दो sets कितने closely साथ move करते हैं, -1 से +1 तक।
In this page:
Syntax
corr = np.corrcoef(x, y)
np.corrcoef()
np.corrcoef एक correlation matrix return करता है। +1 के पास values मतलब variables साथ बढ़ते हैं, -1 के पास मतलब एक बढ़ता है जबकि दूसरा गिरता है, और 0 के पास मतलब कोई linear relationship नहीं। Diagonal हमेशा 1 है।
Note:
off-diagonal entry [0, 1] दो inputs के बीच correlation है।
उदाहरण: np.corrcoef()
import numpy as np
hours = np.array([1, 2, 3, 4, 5])
score = np.array([52, 58, 65, 70, 78])
r = np.corrcoef(hours, score)
print(r.round(3))
print("r =", r[0, 1].round(3))
# Output:
# [[1. 0.998]
# [0.998 1. ]]
# r = 0.998
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- correlation को causation की तरह पढ़ना
- यह भूल जाना कि यह सिर्फ linear relationships detect करता है
- जब NumPy को rows expect हों तब columns pass करना
चैप्टर सारांश
- corrcoef एक matrix return करता है
- Range -1 से +1 है
- Diagonal 1 है
- Rows को variables की तरह treat किया जाता है
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: