-
[๊ธฐ๊ณํ์ต] 12. Dimensionality Reduction๐ณDev/Machine Learning 2022. 1. 1. 14:12
์ถฉ๋จ๋ํ๊ต์ ๊น๋์ผ ๊ต์๋์ ๊ธฐ๊ณํ์ต ์์ ์ ๊ธฐ๋ฐ์ผ๋ก ์ ๋ฆฌํ์ต๋๋ค.
์ค๋์ ์ฐจ์ ์ถ์๋ผ๊ณ ๋ถ๋ฆฌ๋ Dimensionality Reduction์ ๋ํด์ ์์๋ณด์.
1. Dimensionality Reduction, ์ฐจ์ ์ถ์
1) Curse of Dimensionality, ์ฐจ์์ ์ ์ฃผ
๊ฐ์๊ธฐ ์ฐจ์์ ์ ์ฃผ..๋ผ๋ ๋ฌด์จ ๋ง ์ผ๊น?
์ผ๋จ dimension์ ์ผ๋ฐ์ ์ผ๋ก feature(input)์ ์๋ฅผ ์๋ฏธํ๋ค.
๋์์ ๋์ ์ฐจ์์ ์์ญ์ ์ค๋ช ํ๋ ๊ฒ์ ์ง์์ ์ผ๋ก ๋ง์ ๋ฐ์ดํฐ๊ฐ ํ์ํ๋ค.
์๋ฅผ ๋ค์ด 3์ฐจ์ ๊ณต๊ฐ์ ์ต์ 8(2^3)๊ฐ์ ๋ฐ์ดํฐ๊ฐ ๊ณจ๊ณ ๋ฃจ ์ปค๋ฒํ ์ ์๋ค. ๋ฐ๋๋ก ์๊ฐํ๋ฉด 8๊ฐ ๋ฐ์ ์๋ ๋ฐ์ดํฐ๋ฅผ 100์ฐจ์์์ ๋ค๋ฃฌ๋ค๋ ๊ฒ์, ์์ญ์ ๊ณจ๊ณ ๋ฃจ ์ฌ์ฉํ์ง ๋ชปํ๋ ๊ฒ์ ์๋ฏธํ๋ค. 8๊ฐ์ ๋ฐ์ดํฐ๊ฐ 100์ฐจ์์์ ๋งค์ฐ ๊ตญ์ํ ์์ญ์ ์ฐจ์งํ๋ฉฐ, ๊ทธ ๋ง์ 100๊ฐ์ ๋ณ์๊ฐ ์ ๋ถ ๋ฐ์ดํฐ์ ์ํฅ์ ์ฃผ๋ ๊ฒ์ด ์๋๋ผ๋ ๊ฒ์ด๋ค.
๊ทธ๋ฌ๋ ์ํฅ์ ์ฃผ๋ ๋ณ์๋ง ๋ค๋ฃฐ ์ ์๋๋ก, ๋ณ์์ด์ ์ฐจ์์ ์ต๋ํ ์ถ์ํ์ฌ ์ต๋ํ compactํ๊ณ denseํ ํ๊ฒฝ์์ ๋ชจ๋ธ๋ง์ ํด์ผ, ์ ์ฒด ์์ญ์ ๋ํด ๋ชจ๋ธ์ด ๊ณจ๊ณ ๋ฃจ ์ดํดํ ์ ์๋ค.
๋ณ์๊ฐ ๋ง์ ๋(์ฐจ์์ด ๋์ ๋) ์ด๋ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ์์๋ณด์.
- ๋ถํ์ํ ๋ณ์๊ฐ ์กด์ฌ
- ์ค๋ณต๋๋ ๋ณ์๊ฐ ์กด์ฌ
- Overfitting : ์๋ฏธ์๋ ๋ณ์์ ์๋ฏธ ๋ถ์ฌ
- Computational Cost
์ฆ, ์ค์ํ ๋ณ์๋ค์ ๋ชจ๋ ๋ณ์์ ๋ถ๋ถ์งํฉ์ด ๋ ์ ์๋ค!
2) Dimensionality Reduction
์ด์์ ์ธ ์ํฉ
- More features, better performance (under the assumption of independency)
๊ทธ๋ฌ๋ ํ์ค์์๋
- All features cannot be independent to each other, ๋ชจ๋ ๋ณ์๊ฐ ๋ ๋ฆฝ์ ๊ฐ์ ํ๊ธฐ ์ด๋ ต๋ค
- Noise features (including irrelevant, contains lots of noises…), ์ฌ์ฉํ๋ฉด ์ํํ ๋ณ์๋ค์ด ๊ฐ๋
๋ฐ๋ผ์ ์ฐ๋ฆฌ์ ๋ชฉํ๋ '๋ณ์๋ค์ ์์ ๋ถ๋ถ์งํฉ์ ์ ํํด์ ํ์ตํ์!'
- Subset size: as small as possible (Occam’s Razor), ํฌ๊ธฐ๋ ์์ผ๋ฉด ์์ ์๋ก
- Model performance: as good as possible, ์ฑ๋ฅ์ ์ข์ผ๋ฉด ์ข์ ์๋ก
3) Category of Dimensionality Reduction
์, ์ด์ ์ฐจ์์ ์ถ์ํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์๋ณด์. ์ฐจ์ ์ถ์์๋ ๋๊ฐ์ง ๋ฐฉ๋ฒ์ด ์๋ค
1. Feature selection method, ๋ณ์ ์ ํ
- ์๋์ ๋ณ์์์ ์ง์ ๋ช ๊ฐ์ ๋ณ์๋ฅผ ์ ํํ๋ค
- Filter ๋๋ Wrapper ๋ฐฉ๋ฒ์ด ์๋ค
2. Feature extraction method, ๋ณ์ ์ถ์ถ(๊ตฌ์ถ)
- ์๋์ ๋ณ์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์๋ก์ด ๋ณ์๋ฅผ ๊ตฌ์ถํ๋ค by ํจ์
4) Category of Feature Selection
Feature selection method, ๋ณ์ ์ ํ ๋ฐฉ๋ฒ์๋ Filter Approach์ Wrapper Approach๊ฐ ์๋ค.
๊ธฐ์กด ๋ณ์์์ ์ ํํ์ฌ ๋ณ์๋ค์ ๋ถ๋ถ ์งํฉ์ผ๋ก ํ์ต์ ํ๋ ๊ฒ์ ๋๊ฐ์ง๋ง, ์ ํํ๋ ๊ณผ์ ์์ ์ฐจ์ด๊ฐ ์กด์ฌํ๋ค.
- Filter Approach
Dimensionality reduction with one feed-forward preprocessing step
ํ์ต ๋ชจ๋ธ๊ณผ ๋ ๋ฆฝ์ ์ผ๋ก ๋ณ์๋ฅผ ์ ํ - Wrapper Approach
Learning method is involved and gives feed-back to dimensionality reduction process
ํ์ต ๋ชจ๋ธ์ ์ฐธ์ฌ์ ํผ๋๋ฐฑ์ ๋ฐ์ ๋ณ์๋ฅผ ์ ํ
Wrapper๊ฐ ๋ ์ฑ๋ฅ์ด ์ข์ผ๋ฏ๋ก, ์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ณ์ ์ ํ ์๊ณ ๋ฆฌ์ฆ๋ค์ ์์๋ณด๋๋ก ํ์.
2. Feature Selection Method
1) Exhaustive Search
๋ชจ๋ ๊ฒฝ์ฐ์ ๋ณ์๋ค์ ๋ถ๋ถ ์งํฉ์ ์์๋ณด๋ ๋ฐฉ๋ฒ์ด ์์ ์ ์๋ค. ์ฆ, Full Search.
๊ทธ๋ ๋ค๋ฉด O(2^n-1)|n=#๋ณ์ ์ ๋ณต์ก๋๊ฐ ๋์ค๋๋ฐ, ์ง์์๊ฐ์ ๋ณต์ก๋๋ ์ค์ ๋ก ๊ตฌํํ๊ธฐ์๋ ๋งค์ฐ ๋ณต์กํ๋ฏ๋ก ์ฌ์ฉํ์ง ์๋๋ค.
2) Heuristics
Full Search๋ฅผ ํ ์ ์์ผ๋ฏ๋ก, ์ฐ๋ฆฌ๋ Heuristics๋ฅผ ํตํด ๊ทผ์ฌ์น๋ฅผ ๊ตฌํ๋ ค๊ณ ํ๋ค.
๋จผ์ ๊ทผ์ฌ์๋ Approximation๊ณผ Hearistic์ด ์๋๋ฐ, ๊ฐ๋จํ ์ ์๋ ๋ฒ์๋ด์ ๊ทผ์ฌํด๋ผ๋ ๊ฒ์ ์ฆ๋ช ํด์ผ ํ์ง๋ง ํ์๋ ์กฐ๊ธ naiveํ ๊ทผ์ฌ๊ฐ์ ๊ฐ์ง๋ค.
๋ณ์ ์ ํ์ ์ํ Heuristics ์ธ๊ฐ์ง ๋ฐฉ๋ฒ์ ์์๋ณด์. (์ถ๊ฐ์ ์ผ๋ก ๋ช ๊ฐ์ ๋ฐฉ์๋ ํจ๊ป!)
- Forward search
- Backward search
- Stepwise search
3) ๋ณ์์ ํ : Forward Search, ์ ์ง ํ์ ๊ธฐ๋ฒ
๋ณ์๋ฅผ ํ๋์ฉ ์ถ๊ฐํด๊ฐ๋ฉฐ, ๋ชจ๋ธ์ ์ฑ๋ฅ์ ๋์ด๋ ๋ณ์๋ฅผ ์ ํํ๋ greedyํ ๋ฐฉ๋ฒ์ด๋ค.
๋ณ์๊ฐ ํ๋์ผ ๋, ์ ๋ถ ๋๋ ค๋ณด๊ณ ์ต์ ์ ์ ํ์ธ x3๋ฅผ ๊ฐ์ ธ๊ฐ๋ค. ๋ค์์ x3๋ฅผ ํฝ์คํ๋ค ๋ ์ ๋ถ ๋๋ ค๋ณด๋ฉฐ ๋ณ์๊ฐ ๋ ๊ฐ์ผ ๋ ์ต์ ์ ์ ํ์ ์ฐพ์๊ฐ๋ค. ์ด๋ ๊ฒ ๊ณ์ ๋ฐ๋ณตํ์ฌ ์ต์ ์ ๋ณ์๋ค์ ์ฐพ์๋ธ๋ค.
4) ๋ณ์์ ํ : Backward Elimination, ํ์ง ์ ๊ฑฐ ๊ธฐ๋ฒ
์์ ๋ฐ๋๋ก ๋ณ์๋ฅผ ํ๋์ฉ ์ ๊ฑฐํด๋๊ฐ๋ฉฐ ๋ชจ๋ธ ์ฑ๋ฅ์ ์ํฅ์ ์ ์ฃผ๋ ๋ณ์๋ฅผ ์ ๊ฑฐํ๋ ๋ฐฉ๋ฒ์ด๋ค. ์์ ๋ฐฉ์๋ ๋๊ฐ์ด ๋ฐ๋ณต์ ์ผ๋ก ์งํํ๋ค.
5) ๋ณ์์ ํ : Stepwise Search
ํ์ง๋ง ์ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ ๋จ์ ์ ๋๋ฌด greedyํ๋ค๋ ๊ฒ์ด๋ค! greedy๋ ์ง์ญ์ ์ธ ์ต์ ์ ์ํฉ์ด๋ฉฐ, ์ ์ฒด์ ์ธ ์ต์ ์ ์ํฉ์ด ์๋ ์ ์๋ค. ๋ฐ๋ผ์ ์ด์ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฐ์ ํ ๊ฒ์ด Stepwise Search์ด๋ค.
Stepwise๋ ๋จ๊ณ์ ์ผ๋ก forward์ backward๋ฅผ ๊ฐ์ด ์ฌ์ฉํ๋ค. ์ด๋ฐ์๋ forward๋ก ๋ณ์๋ฅผ ์ฑ์์ฃผ๊ณ , ์ดํ๋ถํฐ๋ ๋ ๊ฐ๋ฅผ ๋ฒ๊ฐ์ด ์ฌ์ฉํ๋ฉฐ, ์ถ๊ฐํ๊ณ ๋นผ๊ณ ๋ฅผ ๋ฐ๋ณตํ๋ค.
- Any evaluation criteria can be used, ๋ณ์๋ค์ ์ฑ๋ฅ์ ์ธก์ ํ๋ ํ๊ฐ ์งํ๋ ์ด๋ค ๊ฒ์ด๋ ๊ฐ๋ฅ
์๋ ์งํ๋ ํต๊ณ์์ ์ฃผ๋ก ์ฌ์ฉํ๋ ํ๊ฐ ์งํ๋ค์ด๋ค.
- Akaike Information Criteria (AIC)
SSE + the number of feature selected - Bayesian Information Criteria (BIC)
SSE + the number of feature selected, std. value from the model trained with all features
6) ๋ณ์ ์ ํ : L1 Parameter Regularization
์ถ๊ฐ์ ์ผ๋ก Lasso Regression์ผ๋ก๋ ๋ณ์์ ํ์ ํ ํจ๊ณผ๋ฅผ ์ค ์ ์๋ค.
(ํ์ง๋ง ๊ต์๋์ All in one์ธ Lasso ๋ฐฉ์์ ๋ณ์ ์ ํ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ์ ์ ํธํ์ง ์์ผ์ ๋ค)
- Weight์ ์ ๋๊ฐ์ ์ค์ด๋ ค๊ณ ํ๋ฉฐ,
- Weight๊ฐ 0์ผ๋ก ๊ฐ ๋๊ฐ ์ต์ ์ ์ ํ
- Weight=0 ์ธ ๋ณ์๋ค์ ์์์ ์ํฅ๋ ฅ์ ์์ด ์ ๊ฑฐ๋จ
7) ๋ณ์ ์ ํ : Meta-Heuristic
- Genetic Algorithm (GA)-based search, ์ ์ ์ ์๊ณ ๋ฆฌ์ฆ์ด๋ผ๊ณ ๋ถ๋ฆฐ๋ค
- Exhaustive search: computational cost (but global optimum)
- Local search: search space is very limited -> local optimum (but efficient)
- Main motivation of GA
- Better efficiency than the exhaustive search
- Better solution than the local search
์ฆ, ์ด๋ก ์ ์ผ๋ก local search๋ณด๋ค ์ค๋ ๊ฑธ๋ฆฌ์ง๋ง, global optimum์ ๋๋ฌํ ์ ์๋ ๋ฐฉ์์ด๋ค
- FYI : meta-heuristic
- Heuristic approaches that can be generally used, Heuristic ๋ฐฉ์ ์ค ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ ๋ฐฉ์
- GA, simulated annealing, particle swarm optimization, etc.
8) Genetic Algorithm (GA)
- Evolutionary computing, ์งํ ์ฐ์ฐ์ ํ ๋ถ์ผ
- Meta-heuristic approach์ ๋ฐฉ๋ฒ
- Efficient search for the all search space, ์ ์ฒด ์์ญ์์ ํจ์จ์ ์ผ๋ก ์ฐพ๋๋ค
- (Theoretically) can obtain a global optimum, ์ ์ฒด์ ์ธ ์ต์ ํด๋ฅผ ๊ตฌํ ์ ์๋ค
- (Practically) can obtain a near-global optimum
GA์ ๊ธฐ๋ณธ์ ์ธ ์์ด๋์ด๋ฅผ ๋ณด์. ์ผ๋จ ์ํ๊ณ์์ ์ข ์ ์ธ๋๊ฐ ์ง๋ ์๋ก ์๋์ ๊ฐ์ ๊ณผ์ ์ผ๋ก ์งํ๋ฅผ ํ๋ค.
Evolution Process
- Selection : select two superior parents, ์ฐ์ํ ์ ์ ์๊ฐ ์ ํ๋๊ณ
- Cross-over : select two superior parents, ์์ด์ ์์์ ๋ง๋ ๋ค
- Mutaion : mutate each gene in a rare probability, ๋์์ ๋์ฐ๋ณ์ด๋ ์ผ์ด๋๋ค
์ด๋ฌํ ์ ๋ฆฌ๋ฅผ ์งํ ํ๋ก์ธ์ค๋ผ๊ณ ํ๋ฉฐ, ์ด๋ฅผ ๋ณ์ ์ ํ์ ์ ์ฉํ๋ ค๊ณ ํ๋ค.
์๋๋ ์ ์ฒด์ ์ธ ์์์ด๋ฉฐ, 4๋ฒ๋ถํฐ 7๋ฒ์ด ๊ณ์ ๋ฐ๋ณต๋๋ค.
- Chromosome encoding
- Population setting
- Fitness evaluation
- Selection
- Cross-over
- Mutation
- Create next generation
์ด์ ์์๋๋ก ํ๋ํ๋ ์์๋ณด๋๋ก ํ์.
1. Chromosome encoding
• The number of genes in a chromosome: the number of features, ๋ณ์์ ์งํฉ์ ๋ํ๋ด๋ ํฌ๋ก๋ชจ์ข
• Binary encoding: each gene represents each feature is selected or not, ๊ฐ์ ๋ณ์๊ฐ ์ ํ๋์๋์ง๋ฅผ ์๋ฏธ2. Population setting
- A population consists of p chromosomes, p๊ฐ์ ํฌ๋ก๋ง์ข์ผ๋ก ๊ตฌ์ฑ
- Each chromosome is set randomly, ์ฒ์์๋ ๋๋คํ๊ฒ 20% ์ ๋์ 1์ ํ ๋นํ๋ ํฌ๋ก๋ง์ข์ ๊ตฌ์ฑ
p=500, ์ 500๊ฐ์ ๊ฐ๊ฐ ๋ค๋ฅธ ํฌ๋ก๋ง์ข๋ค์ ์ฌ์ฉํ๋ค.
3. Fitness evaluation
- Fitness๋ ์ ํฉ๋, ์ผ๋ง๋ ์ฐ์ํ Model์ธ๊ฐ? ์ฆ ์ฐ์ํ ์ ์ ์ = ๋ณ์์ธ๊ฐ?
- Fitness can be differ to problems, ์ ํฉ๋๋ ๋ฌธ์ ๋ง๋ค ๋ค๋ฅผ ์ ์๋ค
- Fitness function in feature selection method
- AIC, BIC, Adjusted R2, etc…
- Validation error
- Train each model with each feature set, then calculate fitness function for each model
๊ฐ๊ฐ์ ๋ชจ๋ธ์ ๋ํด์ ์ ํฉ๋๋ฅผ ํ๊ฐํ๋ค
4. Selection
ํ๊ฐ๋ฅผ ํตํด ์ฐ์์ฑ์ ๊ฒ์ฆํ ๋ค, ์ด์ ์ ํ์ ํ๋ค
- With fitness value of each chromosome
- Deterministic selection
- Selection of top n% parents with the fitness values
์์ n%์ ๋ถ๋ชจ๋ค์ ์ ํ
๊ทธ๋ฌ๋ local optimal์ด๋ฉด ์ด๋กํด!
- Selection of top n% parents with the fitness values
- Probabilistic selection
- Fitness value is an weight to be selected
๊ทธ๋์ ์ ํ์ ํ๋ฅ ๊ฐ์ ์ฃผ์ด ๊ฒฐ์ ํ๋ ๋ฐฉ์์ ์ฃผ๋ก ์ฌ์ฉํ๋ค
์๋ ๋๊ทธ๋ผ๋ฏธ ํ์ ๋คํธ๋ฅผ ๋๋ฒ ๋์ ธ์ ๊ฑธ๋ฆฌ๋ฉด ๊ต๋ฐฐ! ํ๋ ๋ฐฉ์
- Fitness value is an weight to be selected
5. Cross-over
- Make two children with two parents, (์์ ์์ํจ์ ์ํด)
๊ฐ๋จํ ์์์ ๋ง๋๋ ๋ฐฉ๋ฒ์๋ ๋ถ๋ชจ์ ์ ์ ์ ์ค ๋๋คํ๊ฒ ๊ณจ๋ผ ์๋ก ๊ตํํด์ฃผ๋ ๋ฐฉ์์ด ์๋ค.
- We can choice different cross-over point, ๊ตํํ๋ ํฌ์ธํธ๋ ์์ ๋กญ๊ฒ ๊ฒฐ์ ํด๋ ๋๋ค
์๋ ์์๋ ํน์ ๋ฒ์๋ฅผ ์ ํ๊ณ ๋๋ค๊ฐ์ ๋ชจ๋ ๋ฐฐ์ด ๊ฐ์ ๋ํด ๊ตฌํด์, ํน์ ๊ฐ ์ด์์ด ๋๋ฉด ๋ฐฐ์ด ๊ฐ์ ๋ณํํด ์ค๋ค.
6. Mutation
์์ ๊ฐ์ ๋ฐฉ์์ ์๋ก์ด ์์ญ์ผ๋ก ์ด๋ํ ์๋ ์๋ค. ๊ทธ๋์ ์ฌ์ฉํ๋ ๊ฒ์ด mutation์ด๋ค.
- With a very small probability (<= 3%) ๋ง์ฝ ๋ฎ์ ๋๋ค๊ฐ์ ๊ฐ์ง๋ฉด ๊ฐ์ ์ ํํด์ค๋ค
- Jump to another search space, ์ด๋ํ๊ธฐ ์ํจ์ด๋ฉฐ
- Escape from local optimal, ๋์์ ์ง์ญ์ ์ต์ ์ ํผํ๊ธฐ ์ํจ์ด๋ค
7. Create next generation
- Make p new chromosomes with p parent chromosomes
- Solution can be evolved through the generation, ์งํ๊ฐ ์งํ๋ ์๋ก ์ฑ๋ฅ์ด ์ข์ ๋ชจ๋ธ์ด ์์ฑ๋๋ค
์๋์ ๊ฐ์ด ์ฑ๋ฅ์ด ์ฐ์ํด์ง์ ์ ์ ์๋ค.
์ฐธ๊ณ ๋ก ์ผ๋ฐ์ ์ผ๋ก 100๊ฐ ์ด์์ p๊ฐ 300~400๋ฒ์ ์ธ๋๋ฅผ ๊ฑฐ์ณ์ผ ์ข์ ์ฑ๋ฅ์ ๊ฐ์ง๋ค.
๋ํ Crosssover์ Mutaion์ ์งํํ ๋ ํ์คํ๊ฒ ๋ณํ๊ฐ ์์ด์ผ, generation์ ๊ฑฐ๋ญํ ์๋ก ์ฌ๋ฌ ์์ญ์ ๋๋ฌ๋ณด๋ฉฐ ์ข์ solution์ ์ฐพ์ ์ ์๋ค.
Set of hyper-parameters
- # of chromosomes in a population, 100๊ฐ ์ด์
- # of generations, 300~500๊ฐ ์ด์ (์ถฉ๋ถํ!)
- Selection method, ํ๋ฅ ์ ์ธ ๋ฐฉ๋ฒ ์ฐ์ธ์!
- Cross-over rate, 50% ์ ๋ ์์ด์!
- Mutation rate, 3%
- Termination criteria, ๋ช ํ ์ด์ ๋๋ ํ๊ท fitness์ ๋ณํ๊ฐ ์์ ๋ ๋ฑ
GA Tips
- Don’t worry about # of population (computing power)
- Probabilistic approach is preferred
- You can try more than two fitness values at one time, ๋๊ฐ์ง ์ ํฉ๋ ๊ณ์ฐ๋ OK
- The best chromosome can always remain (like invincible), ์ต๊ณ ์ ํฌ๋ก๋ง์ข์ ์ธ์ ๋ ๋จ์์๋๋ก ๋ค์์ธ๋๋ก ๋ณต๋ถํด ์ ์งํ๋๊ฑด ๊ต์๋ ํ(์ ๊ต 1๋ฑ์ ์ฐ๋ฆฌํ๊ต์^^)
Pros/Cons
- Meta-heuristic : So we don’t know how close the solution is to the optimal solution
์ค์ ์ ์ฒด์ ์ธ ์ต์ ํด์ ์ผ๋ง๋ ์ ์ฌํ์ง ์ ์ ์๋ค, ๊ทธ๋ฅ ์ด๋ก ์์ผ๋ก! - Solution can be upgraded through a number of evolution
ํด๊ฒฐ๋ฒ์ ์งํ๋ฅผ ํตํด ๊ฐ์ ์ด ๋๋ค - Theoretically, the solution is global optimum
- Be patient, ์ธ๋ด์ฌ ํ์..^^
- Define the fitness function, ๋ฌธ์ ์ ๋ฐ๋ผ ๋ฌ๋ผ์ง ์ ์์ผ๋ฏ๋ก ๋งค์ฐ ์ค์
- If you have a lot of time, but you don’t want to spend your time to think
์๊ฐ์ด ๋ง๋ค๋ฉด ํ ๋ฒ ๋๋ ค๋ณด๋ ๊ฑฐ ์ถ์ฒ - One of optimization methods, but optimization gurus don’t like GA
์์งํ ์ต์ ํ + ์ํ ํ์๋ ๋ถ๋ค์ ๋ณ๋ก ์์ข์ํ๋ค..
3. Feature Extraction
1. Feature Extraction Method
์ด์ ๋ณ์๋ฅผ ์ค์ด๋ ๋๋ฒ์งธ ๋ฐฉ๋ฒ์ธ feature extraction์ ์์๋ณด์
origin ๋ณ์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์๋ก์ด ๋ณ์๋ฅผ ๋ง๋ค์ด๋ด๋ ๋ฐฉ๋ฒ์ผ๋ก, ๋ํ์ ์ผ๋ก PCA๊ฐ ์๋ค.
1) Principal Component Analysis (PCA, ์ฃผ์ฑ๋ถ๋ถ์)
PCA๋ ๋ค์ํ ๋ถ์ผ์์ ๋ง์ด ์ฌ์ฉ๋๋ ๋ถ์๋ฐฉ๋ฒ์ด๋ค.
- Principal : ์ฃผ์ํ
- Component : ์์
- Goal
- Identify bases (axes) that contains the variance of the original data as much as possible
original data์ ๋ถ์ฐ์ ๊ฐ๋ฅํ๋ฉด ์ ์ ์งํ ์์๋ ์๋ก์ด ์ถ์ ์ฐพ๋๋ค(๋ถ์ฐ ์ต๋ํ๊ฐ ๋ชฉํ) - Variable means a lot when the variance is large
์ฆ, ๋ณ์๋ ๋ฐ๋์ง๋ง ๋ณ์๊ฐ ๊ฐ์ง๊ณ ์๋ ์ ๋ณด๋์ ์ ์งํ ์ ์์ด์ผ ํ๋ค
- Identify bases (axes) that contains the variance of the original data as much as possible
์๋ ์ฒซ๋ฒ์งธ ๊ทธ๋ํ๋ฅผ ๋ณด๋ฉด, x1๊ณผ x2๋ฅผ ํตํด data๋ค์ ๋ถ์ฐ์ด ๊ฐ์ฅ ํฐ ์ง์ ์ ๋ง๋ค์๋ค. ๊ทธ๋ฆฌ๊ณ ํด๋น ์ง์ ์ ๊ธฐ์ค์ผ๋ก ํ๋์ ์ด decision boundary๊ฐ ๋ ์ ์๋ค.
์ด๋ x1๊ณผ x2์ผ๋ก ๋ง๋ ๊ทธ๋ํ๊ฐ ์๋ ๋ณ๋์ ์ต๋ํ ๋๊ฐ์ด ์ ์งํ๋ ๊ฒ์ ์ง์ PC1์ ๊ธฐ์ค์ผ๋ก ํ๋ data๋ถํฌ์์, ์ฐ๋ฆฌ๋ ์๋ก์ด 2์ฐจ์ DB๊ฐ ์๋ ๊ฐ๋จํ๊ฒ ๋๋ต 0.7์ด์์ ๋นจ๊ฐ data๊ฐ, ๊ทธ ์ดํ๋ ํ๋ data๊ฐ ์์์ ๋ถ๋ฅํ ์ ์๋ค!
์ด๊ฒ์ด PCA์ด๋ค!
๊ทธ๋ผ ๊ฒ์ ์ง์ , ์ถ์ ์ด๋ป๊ฒ ๊ตฌํ๋๊ฐ?
Dimensionality reduction
- Mapping to a new variable (PC) while keeping the original variance
์๋์ ๋ณ์๋ค์ ํตํด์ ์๋ก์ด ๋ณ์๋ฅผ ๋ง๋๋๋ฐ, ์๋ก์ด ๋ณ์์ ๊ฐ์ ํตํด์ ์๋์ ๋ณ์๊ฐ์ ์ ์ ์๋ค
์ฆ ์ค๋ช ๋ ฅ์ด ๋จ์ด์ง๋ ๋ชจ๋ธ์ด ๋๋ค
์ ์ด์ Mapping์ ํ๊ธฐ ์ ์ ์ ํ๋์์์ ๋ฐฐ์ ๋ ๋ด์ฉ์ ๋ณต์ตํด๋ณด์.
์ฐ๋ฆฌ๋ ๋ฒกํฐ b๋ฅผ a์ ๋งคํํ๋ ค๊ณ ํ๋ค. ์์ ์๋์ ๊ฐ๊ณ , ๊ฒฐ๊ตญ p๋ ๋ฒกํฐ a์ b๋ฅผ ๋ด์ ํ ๊ฒ๊ณผ ๊ฐ๋ค๋ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์๋ค.
๋ค์์ Covariance์ Eigenvector and eigenvalue๋ฅผ ๋ณต์ตํด๋ณด์.
๋๊ฐ์ง๋ฅผ ์ ์ ๋ก ํ์ฌ, ์๋ ์ธ๊ฐ์ง๋ฅผ ๊ธฐ์ตํ๊ณ ๋์ด๊ฐ์
- X์ ํ๊ท ์ด 0์ด๋ฉด Cov๋ (X XT)/n
- Ax = λx
Mapping X to w
- Projected points = wTX
์ฐ๋ฆฌ๋ wTX๋ฅผ ํตํด w๋ฅผ ์์๋ด๋ ค๊ณ ํ๋ค - Covariance of projected points(when X has zero mean value )
where S is covariance matrix of X
๊ณต๋ถ์ฐ์ ์ฌ์ฉํ๊ธฐ ์ํด wTX์ ๊ทธ์ ์ ์นํ๋ ฌ์ ๊ณฑํ๋ค
์ด๋ ์ฐ๋ฆฌ๋ X์ ๊ณต๋ถ์ฐ XXT(S๋ผ ํ์)๋ฅผ ์๊ณ ์์ผ๋ฏ๋ก, ํด๋น ์์ ์ฌ์ฉํ๋ค
์ง๊ธ๊น์ง ์ฐ๋ฆฌ๊ฐ ์ป์ ์ ๋ณด๋ฅผ ์๋ ๋๊ฐ์ง๋ก ์ ๋ฆฌํ ์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ๊ณต๋ถ์ฐ ์ต๋ํ๋ฅผ ์ํ w๋ฅผ ์์๋ณด๋ ๊ฒ์ ๋ชฉํ๋ก ํ๋ค๋ ๊ฒ์ ์์ง๋ง์.
- Max(wT X XT w = wT S w)
- wT w = 1
์์ ๋ ์์์ ๋ณ์๋ w๋ฟ์ด๋ฏ๋ก ์ด๋ฅผ ์ฌ์ฉํ์ฌ ๊ณ์ฐํ๋ค.
๋ํ ๋๊ฐ์ง ๊ฐ์ ๋ ์กด์ฌํ๋๋ฐ
- w๋ unit vector
- X๋ zero mean์ผ๋ก ์ ๊ทํ๋์ด ์์
(L์ ๋ผ๊ทธ๋์ง์) ์ด๋ฅผ ํตํด ์๋ฅผ ๋ง์กฑ์ํค๋ w๋ฅผ ์ฐพ์ ์ ์๋๋ฐ, ์ด๋ eigen vector and eigen value ๋ฌธ์ ์์ ์ ์ ์๋ค!
ํ์ง๋ง S์ ํฌ๊ธฐ์ ๋ฐ๋ผ ๊ทธ๋งํผ์ eigen vector and eigen value์ ์๊ฐ ๋์จ๋ค. ๋ฐ๋ผ์ pc๋ ๊ทธ์ ๋ง๋ ๊ฐ์๋ก ๋์ค๊ฒ ๋๋ค! ๊ทธ๋ฆฌ๊ณ ์ด ๋ชจ๋ pc๋ ์ ๋ถ ๋ ๋ฆฝ์ด๋ฉฐ ์ง๊ฐ์ด๋ค!
์๋์์ ์์์์๋ 2์ฐจ์ ์์ผ๋ก ๋ ๊ฐ์ง์ pc๊ฐ ๋์ค๋ฉฐ, ์ด ๋๊ฐ์ง๊ฐ ์ง๊ฐ์์ ์ ์ ์๋ค.
์์๋ฅผ ๋ณด์.
4๋ฒ์ ๋ถ์ฐ์ค๋ช ๋ ฅ์ ํตํด 5๋ฒ ๋ถ์์ ์งํํ๋ค. ๋ ๋์ ๋น์จ์ ๊ฐ์ง๋ ์์๋๋ก ์ ์ฒด ๋ณํ๋์ ํด๋น eigen vector์ ์ํฅ๋ ฅ์ ์ ์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ์ด๋ฅผ ๊ธฐ์ค์ผ๋ก data๋ค์ ์ฌ๋ ค์ฃผ๋ฉด ๋๋ค!
๊ทผ๋ฐ 2๊ฐ์ ๋ณ์๋ก 2๊ฐ์ pc๋ฅผ ๋ง๋ค๋ฉด, ๊ฒฐ๊ตญ 2๊ฐ์ ๋ณ์๊ฐ ๋๋ ๊ฒ์ด ์๋๊ฐ..?
์๋ ์์๋ฅผ ํ๋ฒ ๋ณด์! 13๊ฐ์ origin ๋ณ์๋ฅผ ํตํด์ 13๊ฐ์ pc๋ฅผ ๋ง๋ค์์ง๋ง, ์ด๋ ์ค์ํ ๊ฒ์ ๋์ ๋ถ์ฐ๋น์ด๋ค.
๋์ ๋ถ์ฐ๋น๊ฐ 93%์ผ๋์ ์ฌ์ฉํ pc ๊ฐ์๋ 7๊ฐ๋ก, origin๋ณด๋ค ์ ์ ์๋ฅผ ๊ฐ์ง๋ค (pc๋ฅผ loading vector๋ผ๊ณ ๋ ๋ถ๋ฅธ๋ค)
๋ฐ๋ผ์ ๊ธฐ์ค์ ์ ํ์ฌ ์ฐจ์ ์ถ์์ ๋ฒ์๋ฅผ ๊ฒฐ์ ํ๋ค.
์ฐจ์์ด ์์์ง ์๋ก ์ค๋ช ๋ ฅ๋ ์ค์ด๋ค์ง๋ง, loading vector(๋ณ์๋ค์ ๋น์จ)๋ฅผ ํตํด ๊ฐ์ ์ ์ผ๋ก ์ค๋ช ์ด ๊ฐ๋ฅํ๋ค.
Number of PC Selected
- d-dimensional original space can make d numbers of PC
- I may select to contain 80~90% of original variance
๋์ ๋ถ์ฐ๋น์ 80-90%๊น์ง pc๋ค์ ์ ํํ ์ ์๋ค
pc 4๊ฐ ์ ๋๋ฅผ ์ฌ์ฉํด๋ ๊ด์ฐฎ์ ๊ฒฐ๊ณผ๊ฐ ๋์จ๋ค
Variations
- Singular Value Decomposition (SVD),
PCA๋ square matrix๋ฅผ ๋ค๋ฃจ์ง๋ง SVD๋ rectangular matrix๋ก ํ์ฅ - Kernel PCA, nonlinerํ mapping๋ ๊ฐ๋ฅ
- Autoencoder(with linear activation function)
NN์ค์์๋ ์์ ๊ธฐ๋ฅ์ ํตํด PCA์ ๊ฐ์ ๊ธฐ๋ฅ์ ์ํํ ์ ์๋ค
'๐ณDev > Machine Learning' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Machine Learning] Learning Rate, Data Preprocessing, Overfitting and DataSet (0) 2022.01.12 [Machine Learning] Regression & Classification (0) 2022.01.10 [๊ธฐ๊ณํ์ต] 11. Kernel Method(Support Vector Machines) (0) 2021.12.26 [๊ธฐ๊ณํ์ต] 10. Deep Neural Networks (0) 2021.12.25 [๊ธฐ๊ณํ์ต] 9. Neural Networks (0) 2021.12.24