4.9.23 · D2 · HinglishProbability Theory & Statistics

Visual walkthroughMultiple regression

2,547 words12 min read↑ Read in English

4.9.23 · D2 · Maths › Probability Theory & Statistics › Multiple regression

Hum sirf assume karte hain ki aap ek graph padh sakte ho aur numbers multiply kar sakte ho. Baaki sab — vectors, "length", "perpendicular", matrices — hum raaste mein earn karte jaayenge.


Step 1 — Hum dekh kya rahe hain? Points aur ek guess

KYA. Hamare paas observations ki ek table hai. Har row ek cheez hai jo humne measure ki: kuch inputs (unhe 's kaho) aur ek output jise hum predict karna chahte hain. Neeche, sirf ek input imagine karo taaki hum use flat paper pe draw kar sakein — poori kahani baad mein generalise hoti hai.

EK DOT AT A TIME SE SHURU KYUN. Kisi bhi algebra se pehle, jo cheez hum minimise karte hain woh ek gap hai: ek real data point aur hamare guessing-line ke beech ka vertical distance. Agar aap us gap ko picture nahi kar sakte, toh koi bhi formula kuch matlab nahi rakhega.

PICTURE. Amber dots data hain. Cyan line trend ki ek guess hai. Dashed white segments vertical gaps hain — guess har point pe kitni galat hai.


Step 2 — Gaps ko square kyun karte hain

KYA. Hum ek line ko score karne ke liye saare gaps add karte hain. Lekin pehle har gap ko square karte hain: haara score hai Yahan sirf "sab add karo" hai, aur hamare paas kitne data points hain.

SQUARE KYUN, SEEDHA ADD KYUN NAHI? Raw gaps mein do problems hain. (1) upar wala point aur neeche wala point pe cancel ho jaate — ek terrible line "perfect" score karti. Squaring sign ko khatam kar deti hai kyunki ek square kabhi negative nahi hota. (2) Squaring score ko ek smooth bowl mein bend kar deti hai, taaki calculus uska bottom exactly dhundh sake (Step 6). Absolute value bhi signs khatam karta hai lekin ek sharp corner hai — koi clean formula nahi.

PICTURE. Har dashed gap literally ek square ban jaata hai (amber). Total shaded area hi score hai. Haara poora kaam: line ko slide aur tilt karo jab tak total amber area as small as possible na ho jaaye.


Step 3 — Data ko arrows (vectors) mein stack karna

KYA. alag-alag numbers ki jagah, saare ko ek tall list mein daalo aur us list ko ek high-dimensional space mein ek single arrow ki tarah treat karo: Bold ab -dimensional space mein rehne wala ek point hai (har data point ke liye ek axis).

YEH BIZARRE CHEEZ KYUN KARTE HAIN? Kyunki "sum of squared gaps" secretly ek squared length hai. Agar do arrows ka gap hai, toh us gap arrow ki squared length exactly hai — haare score jaisi hi shape. Toh minimise karna ban jaata hai: ke sabse kareeb wala arrow dhundho. Distance ek aisi cheez hai jiske liye hamare paas strong geometric intuition hai.

PICTURE. Left: teen numbers . Right: wahi teen numbers 3-D space mein ek arrow ke coordinates ki tarah padhe. Wahi data, nayi nazar.

Iske saath, haara score naye roop mein aata hai:


Step 4 — Haara model kaun se arrows tak pahunch sakta hai? Column space

KYA. Haari prediction hai . Yahan inputs ki table hai (intercept ke liye aage ek column of 1's ke saath), aur coefficients ki list hai jise hum choose kar sakte hain. multiply karne ka matlab hai: Yeh ke columns ka ek weighted blend hai, jisme 's mixing weights hain.

YEH KYUN MATTER KARTA HAI. Jaise hum 's ko saari possible values pe dial karte hain, un columns ke har blend ko sweep karta hai — aur kuch nahi. Reachable arrows ka woh set ek flat sheet hai (ek plane, generally ek hyperplane) jo origin se guzarta hai. Haara data arrow almost kabhi is sheet pe nahi hota (real data noisy hoti hai). Toh hum tak pahunch nahi sakte — hum sirf utna hi kareeb ho sakte hain jitna sheet allow kare.

PICTURE. Do input columns ek tilted cyan plane (column space) span karte hain. Data arrow (amber) plane se bahar niklta hai. Haari har prediction plane ke upar rehti hai.


Step 5 — Sabse kareeb wala point perpendicular ka foot hai

KYA. Flat sheet pe, ke sabse kareeb kaun sa point hai? ko seedha sheet pe girate hain. Landing spot perpendicular ka foot — sabse kareeb reachable point hai.

PERPENDICULAR KYUN, TILTED KYUN NAHI? Landing point ko sheet ke saath-saath kisi bhi direction mein thoda sa slide karo. Agar connecting arrow tilted hota (perpendicular nahi), toh uski tilt ki taraf move karne se gap chhota ho jaata — toh aap abhi minimum pe nahi the. Sirf jab gap arrow sheet ke exactly perpendicular khada ho tab koi sideways nudge kaam nahi kar sakta. Yahi hai "least squares" ka geometric matlab.

PICTURE. Amber residual arrow plane se clean right angle pe milta hai (little white square). Plane pe koi bhi doosra point (grey) se door hai — uska dashed connector lamba hai.


Step 6 — "Perpendicular" ko normal equations mein convert karna

KYA. "Residual sheet ke perpendicular hai" matlab hai ki woh ke har column ke perpendicular hai (columns sheet ko spread karte hain). Do arrows perpendicular hote hain jab unka dot product zero ho. Un saare "" statements ko ek saath bundle karo:

Term by term:

  • — flipped table; uski row hi ka column hai. Isse multiply karne se har predictor column ka dot product compute hota hai jo bhi baad mein aaye uske saath.
  • — residual arrow (data minus prediction).
  • — zeros ka column: har predictor residual ke perpendicular hai.

DOT PRODUCT KYUN? Dot product overlap measure karta hai; yeh exactly tab zero hota hai jab arrows pe milte hain. Yeh "residual aur predictors ke beech koi leftover overlap nahi" state karne ka perfect tool hai.

PICTURE. Har predictor column (cyan) residual (amber) ke saath right angle banata hai. Har ek ka residual ke saath dot product zero padhta hai.

Bracket ko multiply karo — ko subtraction ke across distribute karo:


Step 7 — Coefficients ke liye solve karna

KYA. ko isolate karne ke liye, se multiply karne ko undo karo. Matrix multiply ko undo karna uske inverse se hota hai (matrix version of "divide"). Ise dono sides pe apply karo:

INVERSE KYUN, REAL DIVISION KYUN NAHI? Aap matrix se divide nahi kar sakte. Inverse isliye define kiya jaata hai taaki (identity, "do-nothing" matrix), jo left pe cleanly cancel ho jaata hai aur akela reh jaata hai. Matrix Inverse dekho.

PICTURE. Ek flow: data enter karta hai, predictors ke saath dot hota hai (), phir se rescale hota hai, aur bahar aati hai weight list — jo humhe perpendicular ke foot pe land karati hai.


Step 8 — Degenerate case: jab inverse exist nahi karta

KYA. Step 7 ne quietly assume kiya tha ki exist karta hai. Yeh exist karna fail ho jaata hai jab do (ya zyada) predictor columns ek hi direction mein point karte hain — ek doosre ki copy ya scaled sum hai. Yahi perfect collinearity hai.

GEOMETRICALLY KYUN TOOT JAATA HAI. Agar do columns parallel hain, toh woh ek full plane spread out nahi karte; "sheet" ek lower-dimensional line mein collapse ho jaati hai. Ab infinitely many weight-blends ek hi prediction arrow pe land hote hain — aap ek mein add kar sakte ho aur uske twin se subtract kar sakte ho bina koi visible change ke. Koi unique answer nahi, toh koi inverse nahi.

PICTURE. Left (healthy): do columns fan out karte hain aur ek plane pin karte hain; perpendicular ka foot unique hai. Right (collinear): columns ek single line mein overlap kar jaate hain; projection point unpinned hai — woh slide kar sakta hai, toh unique nahi hai.

Recall

hamesha kam se kam positive semidefinite kyun hota hai? Kisi bhi weight vector ke liye, — yeh ek squared length hai, jo kabhi negative nahi ho sakti. Yeh strictly positive (hence invertible) exactly tab hota hai jab ke columns independent hon (koi collinearity nahi).


Ek-picture summary

Upar sab kuch ek single diagram mein collapse ho jaata hai: data arrow , reachable predictions ki flat sheet ( ka column space), perpendicular drop jo deta hai, aur residual right angle pe khada — jo hai normal equation , jo hai boxed estimator.

Recall Feynman: poora walkthrough plain words mein

Hamare paas data ka ek cloud tha aur hum iske through best flat ramp chahte the. Pehle humne pucha "ek ramp kitni galat hai?" — upar-neeche ke gaps measure karo aur unhe square karo taaki plus aur minus cancel na ho sakein. Phir ek trick: saare outputs ko ek giant arrow mein daalo, toh "sabse chhota total squared gap" ban jaata hai "kaun sa reachable arrow mera data arrow ke sabse kareeb hai?". Ramp sirf arrows ki ek flat sheet tak pahunch sakta hai (input columns ke blends), aur kisi bhi flat sheet pe sabse kareeb spot seedha neeche drop karke milta hai — ek perpendicular. "Leftover gap har input ke perpendicular hai" dot products ke saath likhne se milta hai; matrix multiply undo karne se milta hai. Aur agar do inputs secretly ek hi baat kehte hain, toh sheet collapse ho jaati hai, drop-point slide kar sakta hai, aur koi single answer nahi hota — yahi collinearity hai, aur isliye hum VIF dekhte hain.


Flashcards

Residuals ko directly add karne ki jagah square kyun karte hain?
Taaki positive aur negative gaps cancel na ho sakein, aur score ek smooth bowl ban jaaye jiska unique, calculus-se-dhundhne-wala minimum ho.
Vector picture mein, sum of squared residuals minimise karna kya ban jaata hai?
Woh reachable arrow ( ke column space mein) dhundho jo data arrow ke sabse kareeb ho.
Kaun si geometric fact ko sheet pe sabse kareeb point banati hai?
Residual column space ke perpendicular hai, toh koi sideways nudge use chhota nahi kar sakta.
"Residual har column ke perpendicular hai" equation kaise banta hai?
, yaani normal equations .
Jab do predictor columns collinear hote hain toh kya galat ho jaata hai?
Column space collapse ho jaata hai, projection point unique nahi rehta, invertible nahi hota, toh ka koi unique solution nahi hota.