Multiple features kyun? Real-world phenomena bahut saare variables pe depend karte hain. Single-feature regression confounding factors ko ignore karta hai. Multiple regression is complexity ko capture karta hai agar relationships roughly linear hain.
Har prediction ke liye y^=β0+β1x1+β2x2+⋯ likhna tedious hai. m training examples aur n features ke saath, hamare paas m equations hain. Matrix form ise elegantly compress kar deta hai.
Step 1: Data ko matrices ke roop mein represent karo
m examples ke liye, har ek ke saath n features:
X=11⋮1x1(1)x1(2)⋮x1(m)x2(1)x2(2)⋱x2(m)⋯⋯⋮⋯xn(1)xn(2)xn(m),β=β0β1⋮βn,y=y(1)y(2)⋮y(m)
Leading 1's column kyun? Yeh β0 ka "feature" hai. Intercept ko sirf ek aur coefficient bana deta hai dot product mein.
Step 2: Predictions as matrix multiplication
y^=Xβ
Yeh single equation m alag-alag prediction formulas replace kar deta hai. X ki har row ko β se dot karo to ek prediction milti hai.
Goal: Woh β dhundho jo mean squared error (MSE) minimize kare:
J(β)=m1∑i=1m(y(i)−y^(i))2
Yeh step kyun? Hum woh jagah dhundh rahe hain jahan cost function ka slope zero ho—minimum. Doosra derivative (Hessian X⊤X) positive definite hai, jo confirm karta hai ki yeh minimum hai, maximum nahi.
Normal Equation: Matrix inversion ke liye O(n3) + X⊤X ke liye O(mn2). Dominant cost: inversion.
Kab use karo:
Chota n (< 10,000 features): Normal Equation fast, exact, no hyperparameters
Bada n: Gradient descent use karo (k iterations ke liye O(kmn), k≪n)
Recall 12-Saal Ke Bachche Ko Samjhao
Socho tum guess kar rahe ho ki koi party mein kitni candy khayega. Tumne notice kiya ki teen cheezein matter karti hain: kitna bhookha hai, sweets kitne pasand hain, aur kitne dost paas hain.
Simple regression aisa hai jaise kehna "main sirf bhookh dekhuga aur baaki sab ignore karunga." Yeh silly hai! Multiple regression zyada smart hai: tum ek formula banate ho jo TEENON clues use karta hai, har ek ko ek "weight" deta hai based on kitna important hai.
Toh tumhara formula ho sakta hai: Candy khaya = 5 + 2×(bhookh) + 3×(sweets love) + 1×(dost paas). Computer sabse best weights dhundta hai purani parties dekh kar aur yeh figure out karke ki kaun se numbers sabse kam galat guesses karte hain. Yeh aisa hai jaise ek cheat sheet ho jo ek ki jagah multiple hints use karta hai!
Overfitting: Zyada features → noise fit karne ka risk, regularization chahiye
#flashcards/ai-ml
Multiple linear regression predictions ka matrix form kya hai? :: y^=Xβ, jahan X design matrix hai (intercept ke liye leading 1's ke saath), β coefficient vector hai.
Multiple linear regression ke liye Normal Equation kya hai?
β=(X⊤X)−1X⊤y. MSE ka gradient zero set karke derive kiya jata hai.
Feature matrix X mein 1's ka column kyun add karte hain?
Intercept term β0 ko matrix multiplication Xβ ka part banana ke liye. 1's bias term ke liye "feature" ka kaam karte hain.
X⊤X kab non-invertible hota hai?
Jab (1) m<n (features se kam examples), ya (2) perfect multicollinearity ho (ek feature doosron ka exact linear combination ho).
Jab Normal Equation fail kare toh do alternatives kya hain?
(1) Gradient descent use karo (inversion ki zaroorat nahi), (2) Ridge regression jaisi regularization add karo (X⊤X+λI).
Multiple linear regression mein negative coefficient βi ka kya matlab hai?
Feature xi mein har 1-unit increase ke liye, predicted target y^ mein ∣βi∣ units ki kami aati hai, doosre saare features ko constant rakhte hue.
Multicollinearity kya hai?
Jab features ek doosre se highly correlated hoon (jaise x3≈2x1+x2). Isse coefficient estimates unstable ho jate hain aur variance badh jata hai.
Normal Equation O(n3) complexity kyun hai?
Matrix inversion (X⊤X)−1 ek n×n matrix ke liye O(n3) hai. Yahi cost ko dominate karta hai.
Normal Equation ki jagah gradient descent kab use karna chahiye?
Jab n bada ho (> 10,000 features). Gradient descent k iterations ke liye O(kmn) hai, O(n3) inversion cost se bachata hai.
Coefficient interpretation mein "doosre features ko constant rakhna" ka kya matlab hai?
Coefficient βixi ka y^ pe isolated effect measure karta hai, jaise baaki saare features freeze hain. Multiple regression har feature ka contribution alag karta hai.