From Optimization to Probabilistic Modeling

 

🧠 From Optimization to Probability

So far, we wrote regression as an optimization problem:

minw  Loss+Ξ»Penalty\min_w \; \text{Loss} + \lambda \cdot \text{Penalty}

But we can reinterpret this using probabilistic modeling.


πŸ“˜ Maximum Likelihood Estimation (MLE)

Assume a standard linear regression model:

y=Xw+Ο΅y = Xw + \epsilon

where:

  • Ο΅N(0,Οƒ2)(Gaussian noise)

πŸ”Ή Likelihood

P(yX,w)exp(12Οƒ2(yiwTxi)2)P(y|X,w) \propto \exp\left(-\frac{1}{2\sigma^2} \sum (y_i - w^T x_i)^2 \right)

πŸ”Ή MLE Objective

Maximizing likelihood is equivalent to:

minw(yiwTxi)2\min_w \sum (y_i - w^T x_i)^2

πŸ‘‰ This is just ordinary least squares


πŸ” Maximum A Posteriori (MAP)

Instead of only likelihood, MAP uses:

P(wX,y)P(yX,w)P(w)P(w|X,y) \propto P(y|X,w) \cdot P(w)

πŸ”Ή MAP Objective

Maximize posterior:

maxw  P(yX,w)P(w)\max_w \; P(y|X,w) \cdot P(w)

Take negative log:

minw  logP(yX,w)logP(w)\min_w \; -\log P(y|X,w) - \log P(w)

🎯 Key Insight

Loss+Regularization        Likelihood+Prior\text{Loss} + \text{Regularization} \;\;\Longleftrightarrow\;\; \text{Likelihood} + \text{Prior}

πŸ‘‰ Regularization term = log prior


πŸ”·Ridge Regression as MAP (Gaussian Prior)


πŸ”Ή Assume Prior on Weights

wN(0,Ο„2I)w \sim \mathcal{N}(0, \tau^2 I)

πŸ”Ή Prior Probability

P(w)exp(12Ο„2wj2)P(w) \propto \exp\left(-\frac{1}{2\tau^2} \sum w_j^2 \right)

πŸ”Ή Negative Log Prior

logP(w)wj2-\log P(w) \propto \sum w_j^2

πŸ”Ή MAP Objective

minw((yiwTxi)2+Ξ»wj2)\min_{w} \left( \sum (y_i - w^T x_i)^2 + \lambda \sum w_j^2 \right)


🎯 Conclusion

πŸ‘‰ Ridge regression = MAP with Gaussian prior


🧠 Interpretation

  • Gaussian prior prefers small weights
  • Penalizes large deviations smoothly

πŸ”ΆLASSO as MAP (Laplace Prior)


πŸ”Ή Assume Prior

wLaplace(0,b)w \sim \text{Laplace}(0, b)

πŸ”Ή Prior Probability

P(w)exp(1bwj)P(w) \propto \exp\left(-\frac{1}{b} \sum |w_j| \right)

πŸ”Ή Negative Log Prior

logP(w)wj-\log P(w) \propto \sum |w_j|

πŸ”Ή MAP Objective

minw((yiwTxi)2+Ξ»wj)\min_{w} \left( \sum (y_i - w^T x_i)^2 + \lambda \sum |w_j| \right)


🎯 Conclusion

πŸ‘‰ LASSO = MAP with Laplace prior


🧠 Interpretation

  • Laplace prior is peaked at zero
  • Encourages exact zeros
  • Leads to sparsity

⚖️Why Priors Matter (Key Insight)


πŸ”· Gaussian Prior (Ridge)

  • Smooth bell-shaped curve
  • Penalizes large weights gradually

πŸ‘‰ Result:

  • Shrinkage, but no zeros

πŸ”Ά Laplace Prior (LASSO)

  • Sharp peak at zero
  • Heavy tails

πŸ‘‰ Result:

  • Many weights exactly zero



πŸ“ŠVisual Intuition (Conceptual)

Prior    ShapeEffect
Gaussian        Smooth        Small weights
Laplace        Sharp at zero        Sparse weights

πŸ” Connecting Ξ» to Probability

Ξ»=Οƒ2Ο„2(Ridge)\lambda = \frac{\sigma^2}{\tau^2} \quad (\text{Ridge})

πŸ‘‰ Interpretation:

  • Noise variance vs prior variance
  • Balances data vs prior belief

🧠Big Picture Interpretation


πŸ”Ή Without Regularization (MLE)

  • Only data matters
  • Risk of overfitting

πŸ”Ή With Regularization (MAP)

  • Data + prior belief
  • More robust model

πŸŽ“ Teaching Analogy


MLE:

“Trust only the data”


MAP:

“Trust data, but also apply prior knowledge”


Ridge:

“Weights should be small”


LASSO:

“Most weights should be zero”


🎯 Key Takeaways

  • Regularization = adding prior knowledge
  • Ridge = Gaussian prior → smooth shrinkage
  • LASSO = Laplace prior → sparsity
  • MAP = unifies optimization and probability

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming