๐ฟ Data/์ด๋ชจ์ ๋ชจ
๋ฒกํฐ ๋ด์ ๋ฐ projection
์ฃผ์ด์ง ๋ฐ์ดํฐ (x, y)์ ๋ํด์ y = x ๋ผ๋ ๋ฒกํฐ์ ๋ํด projection์ ๊ณ์ฐํ๋ ํจ์๋ฅผ ์์ฑํ์ธ์. (x, y) ๋ (0, 0) ์์ (x, y)๋ก ๊ฐ๋ ๋ฒกํฐ๋ผ ๊ฐ์ ํฉ๋๋ค. ์ดํ ์ ๋ ฅ๋ ๋ฐ์ดํฐ๋ฅผ ํ๋์ ์ ์ผ๋ก, y = x ๋ผ๋ ๋ฒกํฐ๋ฅผ ๋นจ๊ฐ์ ์ ์ผ๋ก, ๋ง์ง๋ง์ผ๋ก projection ๋ ์ ์ ๋ น์ ์ ์ (dashed)์ผ๋ก ๊ทธ๋ํ์ ๊ทธ๋ฆฌ์ธ์. y=x์ ํด๋นํ๋ ์์์ ๋ฒกํฐ([10, 10])๋ฅผ ์ค์ ํ์ฌ ๋ด์ ๋ฐ projection์ ์งํํ์์ต๋๋ค. import numpy as np v = [7, 4] a = [10, 10] # y = x ์์ ์์์ ๋ฒกํฐ ์ ์ # u๋ v๋ฅผ y = x ์์ projectionํ ๋ฒกํฐ def myProjection(v, a): v = np.array(v) a = np..
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..
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๋ ์ฃผ์ด ํ์ต์ํค๋ ๊ฒ์ผ๋ก ๊ทธ ์ข ๋ฅ์๋ ๋ถ๋ฅ, ํ๊ท ๋ฑ์ด ์๋ค. ์์) ๊ฐ์์ง ์ฌ์ง..
Dimension Reduction(์ฐจ์ ์ถ์)
'Dimension์ด ์ปค์ง๋ค.'์ ์๋ฏธ๋ ๋ฌด์์ผ๊น์? ์ฐจ์์ด ๋์ด๋๋ค. -> ๋ณ์๊ฐ ๋์ด๋๋ค. -> matrix(ํน์ dataframe)์์ ์ด(์นผ๋ผ)์ ์๊ฐ ๋์ด๋๋ค. ์ฐจ์ ์ถ์(Dimensionality Reduction)๋ฅผ ํ๋ ์ด์ ํจ์จ์ฑ์ด ๋จ์ด์ง๋ ๋ณ์๋ฅผ ์ค์ด๊ธฐ ์ํด์(input ๋๋น output์ด ์ข์ง ๋ชปํ ๊ฒฝ์ฐ ; ์ค๋ช ๋ ฅ์ด ๋จ์ด์ง๋ ๊ฒฝ์ฐ) Dimension์ด ์ปค์ก์ ๋ ์ด๋ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ ๊น? ๋จ์ํ๊ฒ ์๊ฐํ๋ฉด, ์ธ๊ฐ์ด ์ดํดํ๊ธฐ(๋น์ทํ๊ฒ ๋ค๋ฅธ ์๋ฏธ๋ก๋ ์๊ฐํํ๊ธฐ) ์ด๋ ค์์ง๋ค. ์ฆ, ์ง๊ด์ ์ผ๋ก ์ดํด๊ฐ ๋์ง ์๋๋ค๋ ๊ฒ ๋ํ, ์ค๋ช ๋ ฅ์ด ๋์ ์ฐจ์(๋ณ์, ์นผ๋ผ)๋ค๋ง ์๋ค๋ฉด ํฐ ๋ฌธ์ ๊ฐ ์๋ ์ ์์ง๋ง ์ค๋ช ๋ ฅ์ด ๋จ์ด์ง๋ ์ฐจ์์ ๊ฒฝ์ฐ ์ธ๋ฐ์์ด ์ปดํจํฐ ๊ณ์ฐ ๊ณผ์ ์ด๋ ๋ฉ๋ชจ๋ฆฌ๋ง ๋ญ๋นํ๋ ๊ผด์ด ๋ ..