2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

5 minute read

2020-1ํ•™๊ธฐ, ๋Œ€ํ•™์—์„œ โ€˜์•Œ๊ณ ๋ฆฌ์ฆ˜โ€™ ์ˆ˜์—…์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋ฐ”๋ฅผ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ์ง€์ ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜์ž…๋‹ˆ๋‹ค :)

์‚ฌ์‹ค ์ด๋ฒˆ์— ๋‹ค๋ฃฐ <Segmented Least Squares>๋Š” ์ •๊ทœ ์ˆ˜์—…์˜ ์ˆ˜์—… PPT์— ํ•œ ํŽ˜์ด์ง€ ๋“ฑ์žฅํ•œ๊ฒŒ ์ „๋ถ€์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ž…๋‹ˆ๋‹ค. ๊ต์žฌ์ธ ใ€ŽAlgorithms(Dasgupta)ใ€์—๋Š” ๊ธฐ์ˆ ๋˜์–ด ์žˆ์ง€ ์•Š์€ ์ฃผ์ œ์ž…๋‹ˆ๋‹ค. ๐Ÿคช


<Linear Regression Problem>์˜ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ์ ‘๊ทผ์ธ <Least Square Method>๋Š” ์ž”์ฐจ์ œ๊ณฑํ•ฉ(residual square sum)์ด ์ตœ์†Œ๊ฐ€ ๋˜๋„๋ก regression ํ•จ์ˆ˜๋ฅผ ์œ ๋„ํ•œ๋‹ค.

<LS Method>์— ๋Œ€ํ•ด ๋” ๊ถ๊ธˆํ•˜๋‹ค๋ฉด, โ€œIntroduction to Linear Regressionโ€ ์•„ํ‹ฐํด์„ ์ฝ์„ ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค ๐Ÿ˜‰

๊ทธ.๋Ÿฌ.๋‚˜. ๋•Œ๋กœ๋Š” ์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ regression ์‹์„ ํ•˜๋‚˜์˜ ์„ ํ˜• ๋ชจ๋ธ๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ์–ด๋ ค์šด ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค. ์ด ๊ฒฝ์šฐ๋Š” ์ฐจ์ˆ˜(degree)๋ฅผ ๋†’์—ฌ ๊ณก์„ ์œผ๋กœ ๋ชจ๋ธ์„ fitting ํ•˜๊ฑฐ๋‚˜ ๊ตฌ๊ฐ„์„ ๋‚˜๋ˆ„์–ด ๊ฐ ๊ตฌ๊ฐ„ ๋ณ„๋กœ regression fitting์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค.

์ด๋ฒˆ์— ๋‹ค๋ฃฐ ์ฃผ์ œ์ธ <Segmented Least Squares> ๋ฐฉ๋ฒ•์€ ํ›„์ž์˜ ๋ฐฉ์‹์œผ๋กœ ๋„๋ฉ”์ธ์„ ๋ถ„ํ• ํ•ด ์–ป์€ segment์— ๋Œ€ํ•ด regression fitting์„ ํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

์œ„์˜ ๊ทธ๋ฆผ์€ ๋„๋ฉ”์ธ์„ 3๊ฐœ์˜ segment๋กœ ๋ถ„ํ• ํ•ด regression fitting ํ•œ ๊ฒฐ๊ณผ์ด๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ๋„๋ฉ”์ธ์„ ๋ถ„ํ• ํ•ด fitting ํ•˜๋Š” ๊ฒฝ์šฐ, ๋„๋ฉ”์ธ์„ ์–ผ๋งˆ๋‚˜ ๋‚˜๋ˆŒ์ง€ ๊ทธ๋ฆฌ๊ณ  ์–ด๋””์—์„œ ๋‚˜๋ˆŒ์ง€ ๋ฏธ๋ฆฌ ์ •ํ•˜๊ณ  fitting์„ ์ง„ํ–‰ํ•œ๋‹ค. ์ฆ‰, segment selection์„ ์ง„ํ–‰ํ•ด์•ผ ํ•œ๋‹ค๋Š” ๋ง์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ <Segmented Least Squares> ๊ธฐ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋ฉด ์–ผ๋งˆ๋‚˜ ๋‚˜๋ˆŒ์ง€ ์–ด๋””์—์„œ ๋‚˜๋ˆŒ์ง€๋ฅผ ์•Œ์•„์„œ ๊ฒฐ์ •ํ•ด fitting ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค€๋‹ค!! ๐Ÿ˜ฒ


<Segmented Least Squares> ๋ฌธ์ œ๋ฅผ ๊ธฐ์ˆ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

For the set of $n$ points in the plane $(x_1, y_1), โ€ฆ, (x_n, y_n)$ with $x_1 \le \cdots \le x_n$.

Let $S(a, b)$ the subset of points where $S(a, b) = \{ (x_i, y_i) \mid a \le i < b \}$, and then let $E(S(a, b))$ be the residual sum of the fitting for $S(a, b)$.

Then, the total residual error is

\[E = \sum_i E(S(t_i, t_{i+1})) \quad \text{where} \quad [t_i, t_{i+1}) \in [x_1, x_n]\]

Find a poly-line that minimizes

\[f(x) = E + c \cdot L\]

where $L$ is the number of segments, and $c$ is a positive constant.

์˜ค์ฐจํ•ฉ $E$๋ฅผ ์ตœ์†Œํ™” ํ•˜๋ ค๋ฉด segment๋ฅผ ์ „์ฒด ๋ฐ์ดํ„ฐ์˜ ์ˆ˜์ธ $n$ ๋งŒํผ ๋‚˜๋ˆ„์–ด fitting์„ ์ง„ํ–‰ํ•˜๋ฉด ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด๋Ÿฐ ๋ชจ๋ธ์€ generalization ์ธก๋ฉด์—์„œ ๊ฒฐ์ฝ” ์ข‹์€ ๋ชจ๋ธ์ด ์•„๋‹ˆ๋‹ค. ๋ฐ˜๋Œ€๋กœ ๋ฐ์ดํ„ฐ๋ฅผ $n$๊ฐœ๋กœ ๋‚˜๋ˆ„์ง€ ์•Š๊ณ  $n$๊ฐœ ์  ์ค‘์— combination์„ ๊ตฌํ•˜๋ ค๊ณ  ํ•œ๋‹ค๋ฉด ๊ทธ๊ฒƒ ์—ญ์‹œ ์กฐํ•ฉํญ๋ฐœ(combinatorial explosion)์— ์ง๋ฉดํ•˜๊ณ  ๋งŒ๋‹ค.

๊ฒฐ๊ตญ <Segmented Least Squares> ๋ฌธ์ œ๋Š” tradeoff function $f(x)$๋ฅผ ํ†ตํ•ด accuracy(goodness of fit)๊ณผ parsimony(number of lines) ์ค‘ ์ ์ ˆํ•œ ๊ท ํ˜•์„ ์ฐพ๋Š” ์ตœ์ ํ™” ๋ฌธ์ œ๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.


<Segmented Least Squares> ๋ฌธ์ œ๋Š” DP๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•„์ฃผ ์‰ฝ๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค!

$DP[j]$๋Š” points $p_1, โ€ฆ, p_j$๊นŒ์ง€ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ์˜ ์ตœ์ ํ•ด์˜ cost๋ฅผ ๋งํ•œ๋‹ค. $e(i, j)$๋Š” โ€œminimum squared from $p_i$ to $p_j$โ€๋ฅผ ์˜๋ฏธํ•˜๋ฉฐ <OLS; Ordinary Least Square>๋กœ ์œ ๋„๋˜๋Š” ๊ฐ’์ด๋‹ค.

์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์•„์ด๋””์–ด๋Š” โ€œ์ถ”๊ฐ€๋˜๋Š” ์  $p_j$๋Š” ์–ด๋–ค ์  $p_i$๋กœ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” segmented fitting์— ์†ํ•  ๊ฒƒ์ด๋‹คโ€์—์„œ ์ถœ๋ฐœํ•œ๋‹ค. ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€ $DP[i-1]$์— ๋Œ€ํ•œ ๊ฐ’์„ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด, ์  $p_j$๋ฅผ ์ถ”๊ฐ€ํ•ด $\{ p_i, โ€ฆ, p_j\}$๋กœ fitting ํ•œ ๊ฒฐ๊ณผ์™€ $p_{i-1}$์—์„œ์˜ optimal fitting ๊ฒฐ๊ณผ๋ฅผ ์ข…ํ•ฉํ•ด ์ตœ์ ํ•ด๋ฅผ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค!

์ด๋ฅผ ๊ธฐ์ˆ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

\[DP[j] = \min_{1 \le i \le j} \left\{ e(i, j) + C + DP[i-1] \right\}\]

์ตœ์ ํ•ด์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ณต์›ํ•  ๋•Œ๋Š” $DP[j]$๋ฅผ ๊ตฌํ•˜๋Š” ๊ณผ์ •์—์„œ ์‚ฌ์šฉ๋œ index $i$๋ฅผ ๋ณ„๋„๋กœ ์ €์žฅํ•œ ํ›„์— back-tracking ํ•˜์—ฌ ๋ณต์›ํ•˜๋ฉด ๋œ๋‹ค!


์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ์œ ๋„ํ•˜๋ฉด,

  • ์ „์ฒด ๊ณผ์ •์—์„œ $O(n^2)$๊ฐœ ๋งŒํผ์˜ $e(i, j)$๋ฅผ ๊ตฌํ•ด์•ผ ํ•จ.
  • $e(i, j)$ ํ•˜๋‚˜์˜ ๊ฐ’์„ ๊ณ„์‚ฐํ•  ๋•Œ $O(n)$ ๋งŒํผ์˜ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆผ.

๋”ฐ๋ผ์„œ ์‹œ๊ฐ„๋ณต์žก๋„๋Š” $O(n^3)$์ด๋‹ค. naiveํ•œ ์ ‘๊ทผ์—์„œ exponential time์ด ๊ฑธ๋ ธ๋˜ ๊ฑธ ์ƒ๊ฐํ•˜๋ฉด ์ •๋ง ํš๊ธฐ์ ์œผ๋กœ ์ค„์–ด๋“  ์…ˆ์ด๋‹ค! ๐Ÿคฉ


<Segmented Least Squares>๋Š” ์ •๊ทœ ์ˆ˜์—…์„ ๋“ค์„ ๋•Œ ๊ณผ์ œ๋กœ ํ•œ๋ฒˆ ๊ตฌํ˜„ํ•ด๋ดค๋˜ ๊ธฐ์–ต์ด ์žˆ๋Š”๋ฐ, ๊ตฌํ˜„์ด ๊ทธ๋ ‡๊ฒŒ ์–ด๋ ต์ง€๋Š” ์•Š์•˜๋˜ ๊ฑธ๋กœ ๊ธฐ์–ตํ•œ๋‹ค.

<Segmented Least Squares> ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๊ณต๋ถ€ํ•˜๋ฉด์„œ โ€œํ†ต๊ณ„์  ๋ฐ์ดํ„ฐ๋งˆ์ด๋‹(IMEN472)โ€์—์„œ ๋“ค์—ˆ๋˜ <Regression Spline>์ด ๋Œ€ํ•ด ๋– ์˜ฌ๋ž๋‹ค. ์ด ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์—ญ์‹œ ๋„๋ฉ”์ธ์„ ๋ถ„ํ• ํ•ด regression fitting ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค.

๋‹ค๋งŒ <Regression Spline>์˜ ๊ฒฝ์šฐ ๊ณก๋ฅ (curverture)๊นŒ์ง€ ๊ณ ๋ คํ•ด fitting์„ ์ง„ํ–‰ํ•˜๋ฉฐ, ๊ตฌ๊ฐ„์„ ์–ผ๋งˆ๋‚˜ ๋‚˜๋ˆŒ์ง€ ์„ ํƒํ•˜๋Š” knot selection์„ cross validation ๊ณผ์ •์„ ํ†ตํ•ด ์ง„ํ–‰ํ•œ๋‹ค๋Š” ์ ์ด <Segmented Least Squares> ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ๋‹ค๋ฅด๋‹ค! ๐Ÿคฉ


reference

Categories:

Updated: