멋쟁이 사자처럼 AI SCHOOL 5기/Today I Learned

[6주차 총정리] t-SNE 개념 정리

lafgh 2022. 4. 26. 02:04

참조: https://gaussian37.github.io/ml-concept-t_sne/

 

t-SNE 개념과 사용법

gaussian37's blog

gaussian37.github.io


 

t-SNE

t-Stochastic Neighbor Embedding, t-분포 확률적 임베딩

Dimensionality Reduction - 비선형 차원 축소

고차원 데이터를 2,3차원으로 줄여 가시화하는데 유용하게 사용된다

매니폴드 학습의 하나로 복잡한 데이터의 시각화가 목적

 

t-SNE 알고리즘은 고차원 공간에서의 점들의 유사성과 그에 해당하는 저차원 공간에서의 점들의 유사성을 계산 (단순히 데이터 사이의 거리를 이용하는 것이 아니라 확률 분포를 이용)

 

https://gaussian37.github.io/ml-concept-t_sne/

 

차원 축소

1. Feature Elimination

2. Feature Selection - information loss 발생 가능, 데이터마다 feature 중요도에 다른 rank

3. Feature Extraction - 새로운 독립적인 feature 만드는 방법 (linear/nonlinear 방법)

   - Linear : PCA

   - Nonlinear : t-SNE

https://www.kaggle.com/questions-and-answers/191055

 

https://quantdare.com/what-is-the-difference-between-feature-extraction-and-feature-selection/
https://quantdare.com/what-is-the-difference-between-feature-extraction-and-feature-selection/

 

from sklearn.manifold import TSNE
from sklearn.datasets import load_digits

# MNIST 데이터 불러오기
data = load_digits()

# 2차원으로 차원 축소
n_components = 2

# t-sne 모델 생성
model = TSNE(n_components=n_components)

# 학습한 결과 2차원 공간 값 출력
print(model.fit_transform(data.data))
# [
#     [67.38322, -1.9517338],
#     [-11.936052, -8.906425],
#     ...
#     [-10.278599, 8.832907],
#     [25.714725, 11.745557],
# ]

왼쪽부터 차례로 PCA, Local Linear Embedding, T-SNE 결과