Difference between revisions of "Linear Methods"
| Line 22: | Line 22: | ||
Some terminology: | Some terminology: | ||
* The '''logit''' function or log-odds is the log of the odds p/(1-p): | * The '''logit''' function or log-odds is the log of the odds p/(1-p): | ||
| − | ::<math>\log \left(\dfrac{p}{1-p} \right) </math> | + | ::<math>\log \left(\dfrac{p}{1-p} \right) = \log(p) - \log(1-p) </math> |
* The '''sigmoid function''' is | * The '''sigmoid function''' is | ||
::<math> \sigma(x) = \dfrac{1}{1+e^{-x}}</math> | ::<math> \sigma(x) = \dfrac{1}{1+e^{-x}}</math> | ||
Revision as of 20:13, 6 February 2021
Metrics
Primary purpose is to minimize some error metric:
[math]\displaystyle{ \displaystyle \textrm{RMSE(}\textbf{X}\textit{,h}) = \sqrt{\dfrac{1}{m} \sum^m_{i=1}(h(\textbf{x}^{(i)} - y^{(i)})^2} }[/math]
[math]\displaystyle{ \displaystyle \textrm{MAE(}\textbf{X}\textit{,h}) = \dfrac{1}{m}\sum^m_{i=1} | h(\textbf{x}^{(i)} - y^{(i)} }[/math]
RMSE gives the Euclidean norm, [math]\displaystyle{ \ell_2 }[/math]. MAE gives the Manhattan norm, [math]\displaystyle{ \ell_1 }[/math]. A higher norm index overweights large values relative to small ones. This makes RMSE more sensitive to outliers than MAE. In general,
[math]\displaystyle{ \|\textbf{v}\|_k = (|v_0|^k + |v_1|^k + \dots + |v_n|^k)^{1/k} }[/math]
Linear Regression
- [math]\displaystyle{ \hat{y} = \theta_0 + \theta_1x_1 + \theta_2x_2 + \cdots + \theta_nx_n = h_\theta(\textbf{x}) = \mathbf{\theta} \cdot \textbf{x} }[/math]
- [math]\displaystyle{ \mathbf{\theta} }[/math] is the parameter vector. The bias term is [math]\displaystyle{ \theta_0 }[/math] and the feature weights are the [math]\displaystyle{ \theta_1 \dots \theta_n }[/math]
- [math]\displaystyle{ \textbf{x} }[/math] is the feature vector of [math]\displaystyle{ x_0 \dots x_n }[/math] where [math]\displaystyle{ x_0 = 1 }[/math]
- [math]\displaystyle{ \mathbf{\theta}\cdot \mathbf{x} }[/math] is the dot product of feature weights and features
- Solve using the normal equation:
- [math]\displaystyle{ \mathbf{\hat{\theta}} = (\mathbf{X}^T\mathbf{X})^{-1} \,\mathbf{X}^T\,\mathbf{y} }[/math]
Logistic Regression
Logistic regression, unlike linear regression, is more of a classifier. It generates probabilities rather than scalar estimates. Some terminology:
- The logit function or log-odds is the log of the odds p/(1-p):
- [math]\displaystyle{ \log \left(\dfrac{p}{1-p} \right) = \log(p) - \log(1-p) }[/math]
- The sigmoid function is
- [math]\displaystyle{ \sigma(x) = \dfrac{1}{1+e^{-x}} }[/math]