Jayden`s
Scree Plot ํ์ฉ๋ฒ
"Scree Plot" ์ ๋ํด์ ์์๋ณด๊ณ , ์์์ PCA๋ก ๋ง๋ ๋ฐ์ดํฐ์ ์ ์ฌ์ฉํ์ฌ ๋ง๋ค์ด๋ณด์ธ์. 90%์ ๋ด์ฉ์ ์ค๋ช ํ๊ธฐ ์ํด์, ๋ช๊ฐ์ PC๋ฅผ ์ฌ์ฉํด์ผ ํ๋์? ์์ ์ฌ๋ฌ ๊ณผ์ ์ ์๋ตํ๊ฒ ์ต๋๋ค. :) ๋จผ์ ๊ฐ ์ฃผ์ฑ๋ถ์ ๋ํ ์์ด๊ฒ๋ฒจ๋ฅ๊ฐ์ ๋ชจ๋ ๋ํ๊ณ ๋๋ , ๊ฐ๊ฐ์ proportion์ ๊ณ์ฐํฉ๋๋ค. values = values / np.sum(values) # ์ ์ ๊ฐ์ ์๊ฐํ plt.title('Scree plot') plt.xlabel('numberofcomp') plt.ylabel('proposion') plt.plot(values); ๊ฐ๊ฐ์ ๊ณ ์ ๊ฐ์ ๋น์ค์ ๊ณ์ฐํด๋ด ๋๋ค. print(values[:2].sum()) print(values[:3].sum..
[TIL]14.Clustering(๊ตฐ์งํ)
๋ชฉํ Scree plot์ ์๋ฏธ Supervised learning(์ง๋ํ์ต)๊ณผ Unsupervised learning(๋น์ง๋ํ์ต)์ ๋ํ ์ดํด(์ฐจ์ด์ ๋ํ ์ดํด) Kmeans clustering์ ๋ํ ์ดํด Scree Plot Machine Learning ์ง๋ ํ์ต(Supervised learning) ํธ๋ ์ด๋ ๋ฐ์ดํฐ์ ๋ผ๋ฒจ(๋ต)์ด ์์ ๋ ์ฌ์ฉํ๋ค. ๋ถ๋ฅ(Classification) ๋ถ๋ฅ ์๊ณ ๋ฆฌ์ฆ์ ์ฃผ์ด์ง ๋ฐ์ดํฐ์ ์นดํ ๊ณ ๋ฆฌ ํน์ ํด๋์ค ์์ธก์ ์ํด ์ฌ์ฉ ํ๊ท(Regression ; prediction) ํ๊ท ์๊ณ ๋ฆฌ์ฆ์ continuousํ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ๊ฒฐ๊ณผ๋ฅผ ์์ธกํ๊ธฐ ์ํด ์ฌ์ฉ ๋น์ง๋ ํ์ต(Unsupervised learning) ๋ผ๋ฒจ๋ง์ด ๋์ด์์ง์์ ๊ฒฝ์ฐ ์ฌ์ฉ, ๋ฐ์ดํฐ์ ํน์ฑ์ ํ ๋๋ก ์์์..
Dendrogram์ ํตํ Clustering ์๊ฐํ ๋ฐ Elbow Method
1. ์ ๊ทํ๋ถํฐ!(๊ฐ ๋ณ์์ ๊ธฐ์ค์ ๋ง์ถ๊ธฐ ์ํด ์ ๊ทํ ์์ ์ ํด์คฌ์ต๋๋ค.) from sklearn.preprocessing import StandardScaler scaler = StandardScaler() Z = scaler.fit_transform(df) Z 2-1. Hierarchical Clustering ๋ฐ Dendrogram์ ํตํ ์๊ฐํ import numpy as np from matplotlib import pyplot as plt from scipy.cluster.hierarchy import linkage, dendrogram from sklearn.cluster import AgglomerativeClustering Z = linkage(Z, method='ward'..
Clustering(๊ตฐ์งํ)
Machine Learning์์ Supervised Learning / Unsupervised Learning / Reinforce Learning 3๊ฐ์ง์ ์ฐจ์ด๋ ๋ฌด์์ผ๊น?(์์๋ ํจ๊ป!) ๋จผ์ Machine Learning(๊ธฐ๊ณ ํ์ต)์ด๋ ์ธ๊ณต์ง๋ฅ์ ํ์ ์งํฉ์ผ๋ก ์ปดํจํฐ๊ฐ ๋ฐ์ดํฐ๋ฅผ ํตํด ํ์ตํ๊ณ ๊ฒฝํ์ ํตํด ๊ฐ์ ํ๋๋ก ํ์ต์ํค๋ ๊ฒ์ ๋งํ๋ค. ๋จธ์ ๋ฌ๋์์ ์๊ณ ๋ฆฌ์ฆ์ ๋๊ท๋ชจ ๋ฐ์ดํฐ์์ ํจํด๊ณผ ์๊ด๊ด๊ณ ๋ฑ์ ๋ถ์์ ํ ๋๋ก ์ต์ ์ ์์ฌ๊ฒฐ์ ๊ณผ ์์ธก์ ์ํํ๋ ๊ฒ์ ์ด์ ์ ๋ง์ถ๋ค. Supervised Learning(์ง๋ํ์ต) : ์ ๋ต์ด ์๋ ๋ฐ์ดํฐ๋ฅผ ํ์ฉํด ๋ฐ์ดํฐ๋ฅผ ํ์ต์ํค๋ ๋ฐฉ๋ฒ. ์ ๋ ฅ๊ฐ์ด ์ฃผ์ด์ง๋ฉด ์ ๋ ฅ๊ฐ์ ๋ํ Label๋ ์ฃผ์ด ํ์ต์ํค๋ ๊ฒ์ผ๋ก ๊ทธ ์ข ๋ฅ์๋ ๋ถ๋ฅ, ํ๊ท ๋ฑ์ด ์๋ค. ์์) ๊ฐ์์ง ์ฌ์ง..
[TIL]13.High Dimensional Data
๋ชฉํ Vector Transformation ์ดํด Eigenvector / Eigenvalue์ ๋ํ ์ดํด ๋ฐ์ดํฐ์ feature ์(์ฐจ์ ์)๊ฐ ๋์ด๋๋ฉด ์๊ธฐ๋ ๋ฌธ์ ์ ๋ฐ ์ด๋ฅผ handlingํ๊ธฐ ์ํ ๋ฐฉ๋ฒ PCA์ ๊ธฐ๋ณธ ์๋ฆฌ์ ๋ชฉ์ ์ ๋ํ ์ดํด Vector transformation R^2 ๊ณต๊ฐ์์ ๋ฒกํฐ๋ฅผ ๋ณํ ์ฆ, ์ ํ ๋ณํ์ ์์์ ๋ ๋ฒกํฐ๋ฅผ ๋ํ๊ฑฐ๋ ํน์ ์ค์นผ๋ผ๊ฐ์ ๊ณฑํ๋ ๊ฒ $$T(u+v)=T(u)+T(v)$$ $$T(cu)=cT(u)$$ ๋ฒกํฐ๋ณํ์ผ๋ก์์ '๋งคํธ๋ฆญ์ค์ ๋ฒกํฐ์ ๊ณฑ' f๋ผ๋ transformation์ ์ฌ์ฉํ์ฌ ์์์ ๋ฒกํฐ [x1, x2]์ ๋ํด [2x1 + x2, x1 - 3x2]๋ก ๋ณํ์ ํ๋ค. \begin{align} f(\begin{bmatrix}x_1 \\ x_2 \end..