2.1.15 · HinglishData Preprocessing & Feature Engineering

Correlation analysis and multicollinearity

2,645 words12 min readRead in English

2.1.15 · AI-ML › Data Preprocessing & Feature Engineering

Overview

Correlation analysis statistical relationship examine karta hai features ke beech, jabki multicollinearity tab hoti hai jab predictor variables aapas mein highly correlated hote hain. Dono hi feature selection aur model interpretability ke liye critical hain.

Figure — Correlation analysis and multicollinearity

Core Concepts


Derivation: Correlation Linear Dependence Kyun Measure Karta Hai

Pehle principles se shuru karo: Hum ek aisa measure chahte hain jo:

  1. Symmetric ho:
  2. Scale-invariant ho: ki units double karne se relationship strength nahi badlni chahiye
  3. "Co-movement" capture kare: jab apne mean se upar ho, to apne mean se upar/neeche hone ki tendency rakhta ho

Step 1: Covariance se co-movement measure karo:

Ye step kyun? positive hota hai jab average se upar ho, negative jab neeche ho. Unka product :

  • Positive hota hai jab dono average se upar/neeche hों (same direction)
  • Negative hota hai jab ek upar ho, ek neeche (opposite direction)

Is product ka average "typical co-movement" deta hai.

Step 2: Normalize karke scale-invariant banao:

Ye step kyun? Covariance ki units hoti hain . Dono standard deviations se divide karne par units hat jaati hain aur ko mein bound kar deta hai (Cauchy-Schwarz inequality se).

Bounds ka proof: Cauchy-Schwarz se, , isliye . Equality tab hoti hai jab (perfect linear relationship).


Multicollinearity Measure Karna


Methods aur Examples


Common Pitfalls


Detection Workflow

Yes

No

Yes

No

Yes

No

Compute Correlation Matrix

High pairwise abs r over 0.8?

Flag feature pairs

Calculate VIF for each feature

VIF over 10?

Multicollinearity detected

Check Condition Number

Remediation: Drop/Combine/PCA/Regularize

kappa over 30?

No severe multicollinearity

Step-by-step:

  1. Pairwise check: Saare feature pairs ke liye compute karo. Agar ho to flag karo.
  2. VIF check: Har feature ke liye, doosron par regress karo, VIF compute karo. Agar ho to flag karo.
  3. Global check: (design matrix ka condition number) compute karo. Agar hai, to matrix ill-conditioned hai.
  4. Action: Har correlated pair se ek feature drop karo, ya PCA use karo, ya L2 regularization apply karo.

Remediation Strategies

  1. Har highly correlated pair se ek feature drop karo (agar hai to rakho, drop karo)
  2. Features combine karo: create karo (jaise, "total_rooms = bedrooms + bathrooms")
  3. Principal Component Analysis (PCA): Uncorrelated components mein transform karo
  4. Regularization: Ridge ( penalty) ya Lasso (, selection bhi karta hai) use karo
  5. Domain knowledge: Jo feature clearer causal interpretation rakhta ho use rakho

Connections

  • Covariance Matrix: Correlation normalized covariance hai
  • Feature Selection: Features drop karne ke liye Correlation ek criterion hai
  • Principal Component Analysis (PCA): Correlated features ko orthogonal components mein transform karta hai
  • Ridge Regression: penalty ke zariye multicollinearity handle karta hai
  • Lasso Regression: Multicollinearity ke under feature selection karta hai
  • Linear Regression Assumptions: Multicollinearity "no perfect colinearity" assumption violate karta hai
  • Variance-Bias Tradeoff: High VIF coefficient estimates ke variance ko inflate karta hai
  • Condition Number: Multicollinearity ka matrix theory perspective

Recall Ek 12-Saal ke Bacche ko Explain Karo

Socho tum figure out karne ki koshish kar rahe ho ki koi video game fun kyun hoti hai, alag-alag features dekh kar: graphics quality, sound quality, story depth, aur number of explosions.

Correlation aise puuchna hai: "Kya better graphics wale games mein better sound bhi hota hai?" Agar haan, to ye correlated hain. Tum ise -1 se 1 tak ke number se measure karte ho:

  • 1 ka matlab hai: Better graphics ka HAMESHA better sound matlab hai (perfect match)
  • 0 ka matlab hai: Graphics aur sound ka ek doosre se koi lena dena nahi
  • -1 ka matlab hai: Better graphics ka HAMESHA worse sound matlab hai (opposite)

Multicollinearity tab hoti hai jab do features itni similar hoti hain ki dono use karna ek hi cheez do baar count karne jaisa hai. Example: "graphics quality" aur "texture resolution" almost same cheez hain! Agar tum dono include karo, to tumhara analysis confuse ho jaata hai—ye nahi bata sakta ki kaunsa actually matter karta hai kyunki dono hamesha saath chalte hain.

Ye bura kyun hai? Socho tum figure out karne ki koshish kar rahe ho ki graphics ya story games ko fun banati hai. Agar tumhare data mein graphics aur story hamesha saath improve hote hain, to tum unke effects alag nahi kar sakte. Ye aise hai jaise figure out karna ki cake mein flour ya sugar tasty banata hai jab tum dono hamesha saath daalte ho—tum bata nahi sakte!

Fix: Similar features mein se ek drop karo (sirf graphics rakho, texture resolution drop karo), ya unhe ek "visual quality" score mein combine karo.


Flashcards

Features X aur Y ke beech -0.85 ka correlation coefficient kya indicate karta hai?
Strong negative linear relationship: jaise X badhta hai, Y proportionally decrease hoti hai. Features highly corre