0. Linear Regression 분류
Linear Regression
├── 1. Error model 기준
│ ├── OLS 계열
│ │ ├── X: fixed or error-free
│ │ ├── y: noise 있음
│ │ └── $\text{Var}(\varepsilon) = \sigma^2\mathbf{I}$
│ │
│ ├── WLS 계열
│ │ ├── X: fixed or error-free
│ │ ├── y: noise 있음
│ │ └── $\text{Var}(\varepsilon) = \text{diag}(\sigma_1^2, \sigma_2^2, \dots, \sigma_m^2)$
│ │
│ ├── GLS 계열
│ │ ├── X: fixed or error-free
│ │ ├── y: noise 있음
│ │ └── $\text{Var}(\varepsilon) = \boldsymbol{\Omega}$
│ │
│ └── TLS 계열
│ ├── X: noise 있음
│ ├── y: noise 있음
│ └── [X y] 전체의 perturbation 최소화
│
├── 2. Regularization 기준
│ ├── No penalty
│ │ ├── OLS
│ │ ├── WLS
│ │ ├── GLS
│ │ └── (Standard) TLS
│ │
│ └── Penalized / Regularized
│ ├── Ridge: L2 penalty
│ ├── Lasso: L1 penalty
│ ├── Elastic Net: L1 + L2 penalty
│ ├── Penalized WLS
│ ├── Penalized GLS
│ └── Regularized TLS
│
└── 3. Optimization / Solver 기준
├── Normal equation 기반 closed-form
│ ├── OLS
│ │ └── $\boldsymbol{\omega}^* = (\mathbf{X}^\top\mathbf{X})^{-1}\mathbf{X}^\top \mathbf{y}$
│ │
│ ├── WLS
│ │ └── $\boldsymbol{\omega}^* = (\mathbf{X}^\top \mathbf{W} \mathbf{X})^{-1}\mathbf{X}^\top \mathbf{W} \mathbf{y}$
│ │
│ ├── GLS
│ │ └── $\boldsymbol{\omega}^* = (\mathbf{X}^\top \boldsymbol{\Omega}^{-1} \mathbf{X})^{-1} \mathbf{X}^\top \boldsymbol{\Omega}^{-1} \mathbf{y}$
│ │
│ └── Ridge
│ └── $\boldsymbol{\omega}^* = (\mathbf{X}^\top \mathbf{X} + \lambda \mathbf{I})^{-1} \mathbf{X}^\top \mathbf{y}$
│
├── Direct decomposition 기반 solver
│ ├── QR decomposition
│ │ └── OLS, WLS, GLS에 사용 가능
│ │
│ ├── SVD
│ │ ├── OLS의 rank-deficient case에 사용 가능
│ │ ├── Ridge 에서 가장 안정적인 Solver임.
│ │ └── Standard TLS의 대표적 solver
│ │
│ └── Cholesky decomposition
│ └── Ridge, WLS, GLS 등 positive definite system에 사용 가능
│
└── Iterative optimization 기반 solver
├── Gradient Descent
├── Stochastic Gradient Descent
├── Coordinate Descent
│ └── Lasso, Elastic Net에서 자주 사용
├── LBFGS
└── 기타 numerical optimization

1. Linear Regression 이란?
Linear Regression(선형회귀)은
- 입력 feature와 target 사이의 선형 관계(linear relationship)를 가정하여
- continuous target 값을 예측하는 대표적인 regression model임.
linear regression(선형회귀)를 matrix(행렬)로 쓰면 다음과 같음:
$$
\mathbf{y} = \mathbf{X}\boldsymbol{\omega} + \boldsymbol{\varepsilon}
$$
학습된 linear regression model의 예측값은 다음과 같음:
$$
\hat{\mathbf{y}} = \mathbf{X} \hat{\boldsymbol{\omega}}
$$
target과 predicted value의 오차는 residual이라 불리며 다음과 같음:
$$
\mathbf{e} = \mathbf{y} - \hat{\mathbf{y}}
$$
각 항의 차원은 보통 다음과 같음.
| 기호 | 의미 | 차원 |
| $\mathbf{X}$ | design matrix | $m \times n$ |
| $\boldsymbol{\omega}$ | parameter, coefficient vector | $n \times 1$ |
| $\hat{\boldsymbol{\omega}}$ | estimated parameter vector | $n \times 1$ |
| $\mathbf{y}$ | target, response vector | $m \times 1$ |
| $\hat{\mathbf{y}}$ | fitted value, predicted response vector | $m \times 1$ |
| $\boldsymbol{\varepsilon}$ | error vector | $m \times 1$ |
| $\mathbf{e}$ | residual vector | $m \times 1$ |
여기서
- $m$은 sample 수, $n$는 feature 수임.
- $\boldsymbol{\varepsilon}$는 실제 data-generating process에서 발생한다고 가정하는 이론적 error term이며, 직접 관측되지 않음.
- 반면 $\mathbf{e}$는 학습된 model의 predicted value와 실제 target의 차이로 계산되는 residual vector임.
- 즉, residual은 관측 불가능한 error term의 proxy로 사용되지만, 두 값이 완전히 같은 것은 아님.
이해를 돕기 위해 훈련데이터로 구성된 desing matrix는 다음과 같음:
$$\mathbf{X} = \begin{bmatrix} - (\mathbf{x}_1)^\top - \\ - (\mathbf{x}_2)^\top - \\ \vdots \\ - (\mathbf{x}_m)^\top - \\ \end{bmatrix} \in \mathbb{R}^{m \times n}$$
참고로, model이 linear하다고 하는 것은
regression 문제에서는 output이 parameters의 linear combination으로 표현되거나,
classification 문제에서는 decision boundary가 hyperplane 형태로 표현되는 경우를 의미함.
classification에서도 decision function은 regression의 prediction formula와 마찬가지로
$f(x)=\boldsymbol{\omega}^\top \mathbf{x} + b$ 이며,
이 decision function이 0이 되는 점들의 집합이 바로 hyperplane (decision boundary)임.
linear regression model의 예측식(prediction function)은 보통 두 가지 형태 중 하나로 기술됨.
1-1. Affine Form
$$
\hat{y}_i = \boldsymbol{\omega}^\top \mathbf{x}_i + b
$$
여기서 $b \in \mathbb{R}$는 intercept 또는 bias라고 불림.
2024.01.03 - [.../Linear Algebra] - [LA] Linear and Affine: Summary
[LA] Linear and Affine: Summary
Linear vs. Affinelinear combination과 linear transform에 같은 linear가 붙는 이유둘 다 원점을 기준으로 한 vector space에서scaling과 addition으로 표현되며,원점 고정성(origin-fixing property)과 선형성(linearity) 같은 lin
dsaint31.tistory.com
1-2. Linear Form (or Homogeneous coordinate form)
모든 Linear transformation은 matrix와의 곱으로 표현가능함.
Affine Form에서 bias를 더하는 부분을 없애기 위해선 Homogeneous Coordinate 를 사용하면 됨.
intercept를 parameter vector와 input vector에 포함하면 다음처럼 쓸 수 있음.
$$
\hat{y}_i = {\boldsymbol{\omega}'}^\top \mathbf{x}'_i
$$
이때 $\mathbf{x}'_i$와 $\boldsymbol{\omega}'$는 다음과 같음.
$$
\mathbf{x}'_i =
\begin{bmatrix}
1 \\
x_{i1} \\
x_{i2} \\
\vdots \\
x_{in}
\end{bmatrix}
\in \mathbb{R}^{n+1},
\qquad
\boldsymbol{\omega}' =
\begin{bmatrix}
b \\
\omega_1 \\
\omega_2 \\
\vdots \\
\omega_n
\end{bmatrix}
\in \mathbb{R}^{n+1}
$$
따라서
$$
{\boldsymbol{\omega}'}^\top \mathbf{x}'_i =
\begin{bmatrix}
b & \omega_1 & \omega_2 & \cdots & \omega_n
\end{bmatrix}
\begin{bmatrix}
1 \\
x_{i1} \\
x_{i2} \\
\vdots \\
x_{in}
\end{bmatrix}
=
b + \sum_{j=1}^{n} \omega_j x_{ij}
$$
이 방식은 affine model을 homogeneous coordinate 형태로 바꾸어 linear form으로 표현한 것임.
정리하면 다음과 같음.
$$
\mathbf{x}_i =
\begin{bmatrix}
x_{i1} \\
x_{i2} \\
\vdots \\
x_{in}
\end{bmatrix}
\in \mathbb{R}^{n},
\qquad
\mathbf{x}'_i =
\begin{bmatrix}
1 \\
x_{i1} \\
x_{i2} \\
\vdots \\
x_{in}
\end{bmatrix}
\in \mathbb{R}^{n+1}
$$
$$
\boldsymbol{\omega} =
\begin{bmatrix}
\omega_1 \\
\omega_2 \\
\vdots \\
\omega_n
\end{bmatrix}
\in \mathbb{R}^{n},
\qquad
\boldsymbol{\omega}' =
\begin{bmatrix}
b \\
\omega_1 \\
\omega_2 \\
\vdots \\
\omega_n
\end{bmatrix}
\in \mathbb{R}^{n+1}
$$
주의할 점은 $\mathbf{x}'_i$와 $\boldsymbol{\omega}'$를 $ (n+1) \times 1$이라고 써도 되지만, 보통은 vector space를 나타낼 때 $\mathbb{R}^{n+1}$로 표기함.
이후로는 편의를 위해 intercept를 포함한 방식을 기본으로 사용하고,
표기는
$\mathbf{X'} \rightarrow \mathbf{X}, \boldsymbol{\omega}' \rightarrow \boldsymbol{\omega}, \mathbf{x}' \rightarrow \mathbf{x}$
로 바꾸어서 사용한다.
2. OLS
2022.04.28 - [Programming/ML] - [Fitting] Ordinary Least Squares : OLS, 최소자승법
[Fitting] Ordinary Least Squares : OLS, 최소자승법
Ordinary Least Squares : OLS, 최소자승법Solution을 구할 수 없는 Over-determined system에서 solution의 approximation을 구하는 가장 기본적인 방법임.Machine Learning에서 Supervised Learning의 대표적인 task인 Regression을
dsaint31.tistory.com
OLS(Ordinary Least Squares)는 $y$ 방향의 residual의 제곱(squared)합을 최소화(least)함.
$$\underset{\boldsymbol{\omega}}{\min}\left\| \mathbf{y} - \mathbf{X} \boldsymbol{\omega} \right\|_2^2$$
residual vector $\mathbf{e}$는 다음과 같음.
$$\mathbf{e} = \mathbf{y} - \mathbf{X}\boldsymbol{\omega}, \qquad \mathbf{e} \in \mathbb{R}^{m}$$
OLS의 기본 error covariance assumption은 다음과 같음:
$$ \operatorname{Var}(\boldsymbol{\varepsilon}) = \sigma^2 \mathbf{I}_m$$
즉,
- 모든 sample의 error variance가 같음: $\text{Var}(\varepsilon_i)= \sigma^2$
- sample 간 error covariance가 0임: $\text{Cov}(\varepsilon_i , \varepsilon_j)=0 \quad, i\ne j$
3. Regularization - Penalty term
OLS 의 objective function 에 penalty term이 추가된 경우로 설명하는 것이 일반적.
(단, WLS, GLS, TLS 등에도 Penalty term을 추가할 수 있음)
주의: Regularization이 된 경우는 Feature Scaling을 해줘야 제대로 동작함.
- Ridge, LASSO, Elastic Net의 penalty는 coefficient 크기에 직접 작용하므로,
- feature scale이 서로 다르면 penalty가 feature별로 공정하게 적용되지 않을 수 있음.
- 단, intercept(=bias) 는 penalty 대상에서 제외하는 게 일반적임.
3-1. Ridge Regression
2025.11.06 - [Programming/ML] - Ridge Regression
Ridge Regression
명칭의 유래Ridge: "산등성이" 또는 "융기"를 의미하는 영어 단어L2-Regularization Term 추가 시 loss function의 contour가 융기된 형태로 변형되는 데에서 유래됨.역사적 배경Tikhonov regularization (1963)과 수학
dsaint31.tistory.com
Ridge Regression은 OLS objective에 L2 penalty를 추가한 방법임.
- 참고로 intercept $b$ 는 penalty 대상에서 제외하는게 일반적임.
여기서 $\mathbf{X}$와 $\boldsymbol{\omega}$ 는 Affine 에서 사용된 형태임($b$가 penalty에서 빠지므로)
Objective function 은 다음과 같음:
$$\underset{\boldsymbol{\omega}, b}{\min} \frac{1}{2m} \| \mathbf{y} - (\mathbf{X} \boldsymbol{\omega} + b\mathbf{1}) \|^2_2 + \alpha \| \boldsymbol{\omega} \| ^2_2$$
Ridge는 다음 형태의 closed-form solution을 가질 수 있음.
$$
\boldsymbol{\omega}^* _{Ridge}
=
\left(
\mathbf{X}^\top \mathbf{X} + \alpha\mathbf{I}_n \right)^{-1} \mathbf{X}^\top \mathbf{y}
$$
- 위 식은 intercept 처리와 centering을 단순화한 표현임.
Closed Form을 가지므로 Direct 방식의 svd, cholesky 등을 사용할 수 있으나,
lsqr, sparse_cg (sparse input), sab, saga, lbfgs (positive=True) 등의 iterative 방식도 사용가능함.
ridge_regression
Precision of the solution. Note that tol has no effect for solvers ‘svd’ and ‘cholesky’. Changed in version 1.2: Default value changed from 1e-3 to 1e-4 for consistency with other linear models.
scikit-learn.org
3-2. LASSO Regression
2025.11.08 - [Programming/ML] - LASSO Regression
LASSO Regression
명칭의 유래LASSO: Least Absolute Shrinkage and Selection Operator 의 약자이름에서 알 수 있듯이,절대값(absolute value) 기반의shrinkage(축소)와feature selection(특성 선택)을 동시에 수행하는 회귀 기법“Shrinkage”
dsaint31.tistory.com
LASSO는 OLS objective에 L1 penalty를 추가한 방법임.
$$
\underset{\boldsymbol{\omega}, b}{\min} \frac{1}{2m} \left\| \mathbf{y} -
( \mathbf{X}\boldsymbol{\omega} + b\mathbf{1} ) \right\|_2^2 + \alpha \|\boldsymbol{\omega}\|_1
$$
LASSO는 weight coefficient shrinkage와 feature selection 효과를 가짐.
LASSO 의 특징:
- OLS + L1 penalty
- sparse weights 를 만듦 (weight shrinkage)
- 일반적으로 coordinate descent (iterative 방식)로 풂
3-3. Elastic Net
https://dsaint31.me/mkdocs_site/ML/ch01/ch01_41/?h=elastic#4-elasticnet
BME
bagging boosting ensemble machine learning random forest regression scikit-learn support vector machine [ML] Classic Regressor (Summary) DeepLearning 계열을 제외한 Regressor 모델들을 간단하게 정리함. 분류 Instance Based Algorithm Mod
dsaint31.me
Elastic Net은 L1 penalty와 L2 penalty를 함께 사용하는 방법임.
$$\underset{\boldsymbol{\omega}, b}{\min}\frac{1}{2m}
\left \| \mathbf{y} - ( \mathbf{X} \boldsymbol{\omega} + b\mathbf{1} ) \right\|_2^2 + \alpha \left( \rho \| \boldsymbol{\omega} \|_1 + \frac{1-\rho}{2} \|\boldsymbol{\omega} \|_2^2 \right)$$
여기서 $\rho$는 L1과 L2의 비율을 조절하는 값임.
scikit-learn에서는 이를 l1_ratio라고 부름.
- L2 penalty 쪽의 $\frac{1}{2}$ 는 미분 시 $2$가 사라지도록 하기 위한 관례적 상수임.
- 따라서 개념적으로는 $\rho$와 $1-\rho$의 혼합으로 이해하면 됨.
- 일반적으로 coordinate descent (iterative 방식)로 풂
4. Error Variance 의 차이
OLS는 $\mathbf{X}$를 fixed 또는 error-free로 두고, $\mathbf{y}$에만 error term $\boldsymbol{\varepsilon}$이 있다고 가정함.
- OLS의 기본 가정은 각 sample의 error variance가 동일하고, 서로 다른 sample의 error term 간 covariance가 0이라는 것임.
WLS와 GLS도 OLS와 마찬가지로 $\mathbf{X}$는 fixed 또는 error-free로 두지만, $\mathbf{y}$의 error term $\boldsymbol{\varepsilon}$에 대한 covariance matrix를 다르게 가정함.
- WLS: 각 sample의 error variance가 다를 수 있으나, 서로 다른 sample의 error term 간 covariance는 0이라고 가정함.
- GLS: 각 sample의 error variance가 다를 수 있으며, 서로 다른 sample의 error term 간 covariance도 0이 아닐 수 있음.
4-1. WLS
2024.06.13 - [.../Math] - [Math] Weighted Least Squares
[Math] Weighted Least Squares
Weighted Least Squares(WLS)는sample마다 error variance가 다를 수 있다고 보고,각 residual 제곱항에 보통 $\frac{1}{\sigma_i^2}$에 비례하는 weight을 주어 추정하는 Least Squares 방법임.아래와 같이 error term의 variance
dsaint31.tistory.com
WLS(Weighted Least Squares)는 sample마다 error variance가 다르다고 보는 방법임.
즉, error covariance matrix가 diagonal matrix인 경우임.
$$
\operatorname{Var}(\boldsymbol{\varepsilon}) =
\begin{bmatrix}
\sigma_1^2 & 0 & \cdots & 0 \\
0 & \sigma_2^2 & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & \sigma_m^2 \\
\end{bmatrix}
$$
따라서 WLS의 error covariance matrix 차원은 다음과 같음.
$$
\operatorname{Var}(\boldsymbol{\varepsilon})
\in
\mathbb{R}^{m \times m}
$$
WLS objective는 다음과 같음.
$$
\underset{\boldsymbol{\omega}}{\min}
\left(
\mathbf{y}
-
\mathbf{X} \boldsymbol{\omega}
\right)^\top
\mathbf{W}
\left(
\mathbf{y}
-
\mathbf{X}\boldsymbol{\omega}
\right) \\ \underset{\boldsymbol{\omega}}{\min} \sum^m_{i=1} w_i (y_i - \mathbf{x}_i^\top \boldsymbol{\omega})^2$$
여기서 $\mathbf{W}$는 weight matrix임.
$$
\mathbf{W}
=
\begin{bmatrix}
w_1 & 0 & \cdots & 0 \\
0 & w_2 & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & w_m
\end{bmatrix}
\in
\mathbb{R}^{m \times m}
$$
보통 weight는 error variance의 inverse에 비례함.
$$
w_i \propto \frac{1}{\sigma_i^2}
$$
즉, measurement error variance가 큰 sample은 덜 믿고, variance가 작은 sample은 더 크게 반영함.
WLS 의 solution 은 다음과 같음:
$$
\boldsymbol{\omega}^*_{WLS}
=
\left(
\mathbf{X}^\top
\mathbf{W}
\mathbf{X}
\right)^{-1}
\mathbf{X}^\top
\mathbf{W}
\mathbf{y}
$$
차원은 다음과 같음.
$$
\mathbf{X}^\top
\mathbf{W}
\mathbf{X}
\in
\mathbb{R}^{(n+1)\times(n+1)}
$$
4-2. GLS
GLS(Generalized Least Squares)는 WLS보다 더 일반적인 Least Squares임.
- WLS는 error covariance matrix가 diagonal인 경우로 각 sample에서의 error variance가 다를 수 있지만 각각은 독립인데 반해,
- GLS는 error covariance matrix가 일반적인 $m \times m$ matrix 로서, 각 sample에서의 error variance가 다를 수 있으면서 각각이 항상 독립이 보장되지 않는 경우임.
Error covariance matrix는 다음과 같음 (대각행렬로 제한되지 않음):
$$
\operatorname{Var}(\boldsymbol{\varepsilon})
=
\sigma^2 \mathbf{\Omega}
$$
- $\mathbf{\Omega}$ :
- Scale-free error covariancee matrix (or Structure matrix)
- 이는 error간의 상관관계 구조와 상대적인 가중치만을 담고 있음.
covariance (공분산) 에 대한 보다 자세한 내용은 다음을 참고:
2022.05.01 - [.../Math] - [Statistics] Covariance vs. Correlation:
[Statistics] Covariance vs. Correlation:
Covariance (공분산)"Covariance" is the raw version of correlation.두 random variable(확률변수)가 얼마나 (선형적으로) 같이 변하는 정도를 나타냄.여러 random variables 에서는 matrix로 기재됨(covariance matrix, $\Sigma$).ma
dsaint31.tistory.com
$$
\mathbf{\Omega} \in \mathbb{R}^{m \times m}
$$
각 원소는 다음을 의미함.
$$
\sigma^2 \Omega_{ij}
=
\operatorname{Cov}
\left(
\varepsilon^{(i)},
\varepsilon^{(j)}
\right)
$$
즉, GLS는 다음을 허용함.
- sample마다 error variance가 다름
- 서로 다른 sample의 error가 correlated 될 수 있음
GLS objective는 다음과 같음.
$$
\underset{\mathbf{\omega}}{\min}
\left(
\mathbf{y}
-
\mathbf{X}\boldsymbol{\omega}
\right)^T
\mathbf{\Omega}^{-1}
\left(
\mathbf{y}
-
\mathbf{X}\boldsymbol{\omega}
\right)
$$
GLS 해는 다음과 같음.
$$
\boldsymbol{\omega}^*_{GLS}
=
\left(
\mathbf{X}^\top
\mathbf{\Omega}^{-1}
\mathbf{X}
\right)^{-1}
\mathbf{X}^\top
\mathbf{\Omega}^{-1}
\mathbf{y}
$$
OLS, WLS, GLS의 포함 관계는 다음과 같음.
$$
\text{OLS} \subset \text{WLS} \subset \text{GLS}
$$
단, 여기서 포함 관계는 “error covariance structure의 일반성” 기준임.
5. TLS
2024.06.22 - [Programming/ML] - [Fitting] Total Least Squares Regression
[Fitting] Total Least Squares Regression
Total Least Squares (TLS) RegressionTotal Least Squares (TLS) 회귀는 데이터의 모든 방향에서의 오차를 최소화하는 회귀 방법임.이는 특히 독립 변수 와 종속 변수 모두에 오차가 포함되어 있는 경우에 유용함
dsaint31.tistory.com
TLS(Total Least Squares)는 OLS, WLS, GLS와 관점이 다름.
- OLS, WLS, GLS는 기본적으로 $\mathbf{X}$는 fixed 또는 error-free라고 보고, $\mathbf{y}$ 쪽 residual을 최소화함.
- 반면 TLS는 $\mathbf{X}$와 $\mathbf{y}$ 양쪽에 measurement error가 있다고 봄.
OLS 계열에서는 이상적인 경우의 모델은 다음과 같음:
$$\mathbf{y}=\mathbf{X}\boldsymbol{\omega}+\boldsymbol{\varepsilon}$$
하지만 TLS에서는 관측된 $\mathbf{X}$와 $\mathbf{y}$ 모두 오차를 포함한다고 봄.
$$
\left( \mathbf{X} + \Delta \mathbf{X} \right)\boldsymbol{\omega}
=
\mathbf{y} + \Delta \mathbf{y}
$$
TLS는 다음 perturbation (작은 변화량,수정량을 뜻함: correction)을 최소화함.
( $ 전체의 Euclidean perturbation을 최소화하기 때문에 Feature Scaling이 매우 중요)
$$
\underset{\Delta \mathbf{X}, \Delta \mathbf{y}, \boldsymbol{\omega}}{\min}
\|
\left[
\Delta \mathbf{X}
\
\Delta \mathbf{y}
\right]
\|_F^2
$$
subject to
$$
( \mathbf{X} + \Delta \mathbf{X}) \boldsymbol{\omega}
=
\mathbf{y} + \Delta \mathbf{y}
$$
- 여기서 $\| \mathbf{A} \| _F = \displaystyle \sqrt{ \sum^m_{i=1} \sum^n_{j=1} a^2 _{ij} }$ 이며, Frobenius norm이라고 불림.
- 위의 식에선 $\mathbf{X}$와 $\mathbf{y}$에서 발생한 모든 correction (or error) 의 제곱합임.
$\Delta \mathbf{X}$와 $\Delta \mathbf{y}$는
실제 관측값에 섞여 있다고 가정하는
measurement error 또는
해당 error를 제거하기 위한 작은 correction으로 해석됨.
즉, 이들의 모든 원소를 각각 제곱하여 합한 값을 최소화하는 것이 TLS에서 요구됨.
TLS에서 augmented data matrix는 다음과 같음.
$$
\mathbf{A}
=
[
\mathbf{X}
\
\mathbf{y}
]
$$
차원은 다음과 같음.
$$
\mathbf{A}
\in
\mathbb{R}^{m \times (n+2)}
$$
여기서 $\mathbf{X}$가 intercept column을 이미 포함하므로 $(n+1)$개의 column을 가지고, $\mathbf{y}$ column이 하나 더 붙어 총 $(n+2)$개 column이 됨.
Standard TLS는
보통 SVD를 이용해 풂.
TLS 의 특징
- $\mathbf{X}$ 와 $\mathbf{y}$ 양쪽에 measurement error 존재
- vertical residual이 아니라 orthogonal residual 관점
- augmented matrix $\left[ \mathbf{X} \ \mathbf{y} \right]$ 사용
- 대표 solver: SVD
기본 TLS는 SVD 기반 closed-form/direct solution이 가능하지만,
penalty, 구조 제약, weight, robustness 조건등이 들어간 TLS는
iterative optimization으로 푸는 것이 보다 일반적임.
참고: 차원 정리
intercept를 포함한 경우임.
| 기호 | 의미 | 차원 |
| $m$ | sample 수 | scalar |
| $n$ | feature 수 | scalar |
| $\mathbf{X}$ | intercept 포함 design matrix | $m \times (n+1)$ |
| $\boldsymbol{\omega}$ | itercept 포함 parameter vector | $(n+1) \times 1$ |
| $\mathbf{y}$ | target vector | $m \times 1$ |
| $\hat{\mathbf{y}}$ | predicted value vector | $m \times 1$ |
| $\mathbf{e}$ | residual vector | $m \times 1$ |
| $\boldsymbol{\varepsilon}$ | error vector | $m \times 1$ |
| $\mathbf{W}$ | WLS weight matrix | $m \times m$ |
| $\mathbf{\Omega}$ | GLS error covariance matrix | $m \times m$ |
| $\mathbf{X}^\top \mathbf{X}$ | feature-feature Gram matrix | $(n+1)\times(n+1)$ |
| $\mathbf{X}^\top \mathbf{W} \mathbf{X}$ | WLS parameter system matrix | $(n+1)\times(n+1)$ |
| ${\mathbf{X}}^\top \mathbf{\Omega}^{-1} \mathbf{X}$ | GLS parameter system matrix | $(n+1)\times(n+1)$ |
| $[\mathbf{X}\ \mathbf{y}]$ | TLS augmented matrix, intercept 포함 | $m \times (n+2)$ |
요약
- sample 수를 $m$, feature 수를 $n$으로 두면, intercept를 포함한 design matrix는 $\mathbf{X}\in\mathbb{R}^{m\times (n+1)}$임.
- OLS는 $y$ 방향 residual의 제곱합을 최소화하는 기본 least squares임.
- Ridge, LASSO, Elastic Net은 OLS objective에 regularization penalty를 추가한 penalized least squares 계열임.
- WLS는 sample별 error variance가 다를 때 diagonal weight matrix $\mathbf{W}\in\mathbb{R}^{m\times m}$를 사용하는 방법임.
- GLS는 sample error들 사이의 covariance까지 포함하여 $\mathbf{\Omega}\in\mathbb{R}^{m\times m}$를 사용하는 WLS의 일반화임.
- TLS는 $X$와 $y$ 양쪽에 measurement error가 있다고 보고, vertical residual이 아니라 orthogonal residual 또는 total perturbation을 최소화하는 방법임.
- Normal equation, QR, SVD, WLS direct solve, GLS direct solve는 direct linear algebra 계열이고, GD, SGD, coordinate descent는 iterative optimization 계열임.
- OLS와 WLS에서는 feature scaling이 필수는 아니지만, Penalized Linear Regression과 TLS에서는 scale이 objective function에 직접적인 영향을 주므로 일반적으로 scaling을 수행해야 함.
같이보면 좋은 자료들
https://dsaint31.me/mkdocs_site/ML/ch01/ch01_41/
BME
bagging boosting ensemble machine learning random forest regression scikit-learn support vector machine [ML] Classic Regressor (Summary) DeepLearning 계열을 제외한 Regressor 모델들을 간단하게 정리함. 분류 Instance Based Algorithm Mod
dsaint31.me
2022.05.01 - [.../Math] - [Statistics] Covariance vs. Correlation:
[Statistics] Covariance vs. Correlation:
Covariance (공분산)"Covariance" is the raw version of correlation.두 random variable(확률변수)가 얼마나 (선형적으로) 같이 변하는 정도를 나타냄.여러 random variables 에서는 matrix로 기재됨(covariance matrix, $\Sigma$).ma
dsaint31.tistory.com
2024.06.13 - [.../Math] - [Math] Weighted Least Squares
[Math] Weighted Least Squares
Weighted Least Squares(WLS)는sample마다 error variance가 다를 수 있다고 보고,각 residual 제곱항에 보통 $\frac{1}{\sigma_i^2}$에 비례하는 weight을 주어 추정하는 Least Squares 방법임.아래와 같이 error term의 variance
dsaint31.tistory.com
2024.06.22 - [Programming/ML] - [Fitting] Total Least Squares Regression
[Fitting] Total Least Squares Regression
Total Least Squares (TLS) RegressionTotal Least Squares (TLS) 회귀는 데이터의 모든 방향에서의 오차를 최소화하는 회귀 방법임.이는 특히 독립 변수 와 종속 변수 모두에 오차가 포함되어 있는 경우에 유용함
dsaint31.tistory.com
'Programming > ML' 카테고리의 다른 글
| Balanced Accuracy (균형 정확도) (0) | 2026.05.26 |
|---|---|
| [ML] BFGS, L-BFGS, L-BFGS-B : Quasi-Newton method (0) | 2026.04.27 |
| Bootstrap Sampling 기반 Accuracy 추정 지표 (0) | 2026.04.14 |
| XAI: Coefficient, Feature importance, and SHAP (0) | 2026.03.24 |
| ULMFit : Transfer Learning for NLP (0) | 2026.01.16 |