Section1_sprint3
ํค์๋ ์์ฃผ๋ก ์ ๋ฆฌ
set : list์ ๋น์ท, ๋จ ์ค๋ณต์น ํ์ฉ x ์์ ๊ฐ๋ x
Determinant
๋ชจ์ง๋จ : population -> parameter
ํ๋ณธ์ง๋จ : sample -> statistic
Covariance(๊ณต๋ถ์ฐ)
Correlation coefficient(์๊ด๊ณ์) : ๊ณต๋ถ์ฐ์ ์ค์ผ์ผ๋งํ ๊ฒ
๋ณดํต ์ฐ๋ฆฌ๊ฐ ์๋ ์๊ด๊ณ์๊ฐ Pearson Corr์ด๊ณ categorical data์ ์์๋ฅผ ๋ถ์ฌํ๊ณ ์ด๋ฅผ ํ ๋๋ก corr์ ๊ตฌํ๋ ๊ฒSpearman Corr
-> ๋ฐ์ดํฐ๊ฐ ๊ฐ๋ ๊ฐ์ด ์๋ ์ฐ๋ฆฌ๊ฐ ๋ถ์ฌํ '์์ ํน์ ์์'๋ก๋ง ์๊ด๊ณ์๋ฅผ ๋ฐ์ง๋ค.
๋จ์๋ฒกํฐ : ๊ธธ์ด๊ฐ 1์ธ ๋ฒกํฐ
Span : ์ฃผ์ด์ง ๋ฒกํฐ์ ์กฐํฉ์ผ๋ก ๋ง๋ค ์ ์๋ ๋ชจ๋ ๊ฐ๋ฅํ ๋ฒกํฐ์ ์งํฉ
Basis : ์ด๋ค ๊ณต๊ฐ U๋ฅผ ์ฑ์ธ ์ ์๋ ์ ํ๊ด๊ณ์ ์์ง ์์ ๋ฒกํฐ๋ค
Orthogonal Basis : Basis ์ค์์๋ ์์ง๊ด๊ณ์ ์๋ ์กฐํฉ
rank : ์ด๋ค ๊ณต๊ฐ U์ ์ฐจ์
Gaussian Elimination
Linear projection
์ฐจ์ ์ถ์(ํน์ฑ ์ค์ด๊ธฐ) ๊ฐ๋ ๊ณผ ์ฎ์ด์ ๊ธฐ์ต -> ์ฝ๊ฐ์ ์ ๋ณด๋ฅผ ํฌ๊ธฐํ๊ณ ๋ฉ๋ชจ๋ฆฌ ํ๋ณด
๊ณ ์ ๋ฒกํฐ(eigen vector) : matrix๋ฅผ ํตํ transformation์ ๋ํด ํฌ๊ธฐ๋ง ๋ณํ๊ณ ๋ฐฉํฅ์ ์ ์งํ๋ ๋ฒกํฐ
Ax = ฮปx (A๋ ํ๋ ฌ, x๋ ๋ฒกํฐ, ฮป๋ scalar ๊ฐ์ผ๋ก '๊ณ ์ณ๊ฐ')
๊ณ ์ฐจ์ ๋ฌธ์ (์ฐจ์์ ์ ์ฃผ) ํด๊ฒฐ
Feature Selection ex) ํน์ฑ ์ ๊ฑฐ(drop)
Feature Extraction ex) PCA(๊ธฐ์กด ์ปฌ๋ผ์์ ๋ ์ ์๋ฏธํ ์ปฌ๋ผ์ ๋ง๋ค์ด๋ด๋ ๊ฒ)
PCA(Principal Component Analysis)
๊ฐ์ฅ ๋ฐ์ดํฐ์ ์๋ ๋ถํฌ๋ฅผ ์ ์ค๋ช
ํด์ฃผ๋ ์ถ์ projection(์ต๋ํ ๋ถ์ฐ์ ์ ์งํ๋ฉด์ ํน์ฑ์ ์ค์ด๋)
์์1)
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
%matplotlib inline
from sklearn.datasets import make_blobs # ๋๋คํ๊ฒ ์๋ฎฌ๋ ์ด์
๋ฐ์ดํฐ๋ฅผ ์์ฑํ ๊ฒ์ด๋ค.
from sklearn import decomposition
X1, Y1 = make_blobs(n_features = 10, n_samples = 100, centers = 4, random_state = 4, cluster_std = 2) ## random ํ๊ฒ simulation data ์์ฑ
pca = decomposition.PCA(n_components = 4)
pc = pca.fit_transform(X1)
pc_df = pd.DataFrame(data = pc, columns = ['PC1', 'PC2', 'PC3', 'PC4'])
pc_df['Cluster'] = Y1
pc_df.head()
์ด ๋, ์ฐจ์์ ๋ช๊ฐ๋ก ์ถ์ํ ์ง ์ ํ ๋ ๋ณด๋ ๊ฒ scree plot
์์2)
def scree_plot(pca):
num_components = len(pca.explained_variance_ratio_)
ind = np.arange(num_components)
vals = pca.explained_variance_ratio_
ax = plt.subplot()
cumvals = np.cumsum(vals)
ax.bar(ind, vals, color = ['#00da75', '#f1c40f', '#ff6f15', '#3498db']) # Bar plot
ax.plot(ind, cumvals, color = '#c0392b') # Line plot
for i in range(num_components):
ax.annotate(r"%s" % ((str(vals[i]*100)[:3])), (ind[i], vals[i]), va = "bottom", ha = "center", fontsize = 13)
ax.set_xlabel("PC")
ax.set_ylabel("Variance")
plt.title('Scree plot')
scree_plot(pca)
์ง๋ํ์ต vs ๋น์ง๋ํ์ต vs ๊ฐํํ์ต
Cluster(๊ตฐ์งํ)
- ๋น์ง๋ํ์ต ์ค ํ๋(label ์์)
- K-means clustering์ด ๋ํ์ -> K๊ฐ์ ๊ตฐ์ง์ ๋ง๋ค ๊ฒ์ด๊ณ ๊ทธ ๊ตฐ์ง์ ์ค์ฌ(๊ธฐ์ค)์ mean(ํ๊ท )์ ์ด์ฉํ์ฌ ์ ํ๊ฒ ๋ค๋ ์๋ฏธ
๊ณผ์
- k๊ฐ์ ๋๋คํ ๋ฐ์ดํฐ๋ฅผ cluster์ ์ค์ฌ์ ์ผ๋ก ์ค์
- ํด๋น cluster์ ๊ทผ์ ํด ์๋ ๋ฐ์ดํฐ๋ฅผ cluster๋ก ํ ๋น
- ๋ณ๊ฒฝ๋ cluster์ ๋ํด ์ค์ฌ์ ์ ์๋ก ๊ณ์ฐ
- cluster์ ์ ์๋ฏธํ ๋ณํ๊ฐ ์์ ๋๊น์ง 2~3๋ฒ์ ๋ฐ๋ณต
- k๋ฅผ ๊ฒฐ์ ํ๋ ๋ฐฉ๋ฒ(๋ช๊ฐ์ ๊ตฐ์ง์ผ๋ก ๋๋์ง) : Elbow method -> PCA ์ scree plot๊ณผ ์ด์ง ๋ฎ์์์
cf) K-means๋ KNN์ด๋ ๋ค๋ฅด๋ค.ํท๊ฐ๋ฆฌ์ง ๋ง๊ธฐ
'๐ฟ Data > ๋ถํธ์บ ํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[TIL]48_DataBase, SQL_Basics(SQLite) (0) | 2022.01.19 |
---|---|
[TIL]47_Git&Github and conda(๊ฐ์ํ๊ฒฝ) (0) | 2022.01.19 |
[TIL]45.8_Section1_sprint2_๊ฐ์ธ๋ณต์ต(์ฃผ๋ง) (0) | 2022.01.17 |
[TIL]45.3_Section2_sprint3_๊ฐ์ธ๋ณต์ต(์ฃผ๋ง) (0) | 2022.01.16 |
[TIL]45.5_Section1_sprint1_๊ฐ์ธ๋ณต์ต(์ฃผ๋ง) (0) | 2022.01.16 |