Skip to content
Snippets Groups Projects
Commit de50a39a authored by Felix Ramnelöv's avatar Felix Ramnelöv
Browse files

Lab 1: Ridge function fix

parent b1bf708c
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ log_likelihood <- function(theta, sigma) {
# Ridge
ridge <- function(theta, sigma, lambda) {
ridge <- lambda * sum(theta ^ 2) - log_likelihood(theta, sigma)
ridge <- - log_likelihood(theta, sigma) + lambda * sum(theta ^ 2)
return(ridge)
}
......
......@@ -105,7 +105,7 @@ Confusion matrix o misclassification error e framtana.
3. The functions where implemented using the following formulas:
- _Loglikelihood_: $$\log P(T | \theta, \sigma) = -\frac{n}{2} \log(2 \pi \sigma^2) - \frac{1}{2 \sigma^2} \sum_{i=1}^{n} (T_i - \mathbf{X}_i \boldsymbol{\theta})^2$$
- _Ridge_: $$\mathcal{L}_{\text{ridge}}(\theta, \sigma, \lambda) = \lambda \sum_{j=1}^{p} \theta_j^2 - \log P(T | \theta, \sigma)$$
- _Ridge_: $$\mathcal{L}_{\text{ridge}}(\theta, \sigma, \lambda) = - \log P(T | \theta, \sigma) + \lambda \sum_{j=1}^{p} \theta_j^2$$
- _RidgeOpt_: $$\hat{\theta}, \hat{\sigma} = \arg \min_{\theta, \sigma} \mathcal{L}_{\text{ridge}}(\theta, \sigma, \lambda)$$
- _DF_: $$\text{df}(\lambda) = \text{tr}\left( X \left( X^T X + \lambda I \right)^{-1} X^T \right)$$
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment