DBSCAN
: 밀도 기반 클러스터링 : kmeans와 달리 k를 지정하지않음
- 이론
[데이터 마이닝] DBSCAN과 밀도 기반 클러스터링
1. 밀도 기반 클러스터링 (Density-based clustering) 클러스터링 알고리즘은 크게 중심 기반 (center-based) 알고리즘과 밀도 기반 (density-based) 알고리즘으로 나눌 수 있다. 중심 기반 알고리즘의 가장 대표
untitledtblog.tistory.com
- K-Means / DBSCAN 동작 보기
https://www.naftaliharris.com/blog/visualizing-dbscan-clustering/
Visualizing DBSCAN Clustering
January 24, 2015 A previous post covered clustering with the k-means algorithm. In this post, we consider a fundamentally different, density-based approach called DBSCAN. In contrast to k-means, which modeled clusters as sets of points near to their center
www.naftaliharris.com
* cluster6_dbscan
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import make_moons
from sklearn.cluster import KMeans, DBSCAN, AgglomerativeClustering
x, y = make_moons(n_samples = 200, noise = 0.05, random_state=0)
print(x)
print(y)
plt.scatter(x[:, 0], x[:, 1])
plt.show()
from sklearn.datasets import make_moons
make_moons(n_samples = 샘플수, noise = 노이즈 정도, random_state=난수seed) :
def plotResult(x, y):
plt.scatter(x[y == 0, 0], x[y == 0, 1], c='blue', marker='o', label='clu-1')
plt.scatter(x[y == 1, 0], x[y == 1, 1], c='red', marker='s', label='clu-2')
plt.legend()
plt.show()
- KMEANS 사용 : 완전한 분리 X
km = KMeans(n_clusters=2, random_state=0)
pred1 = km.fit_predict(x)
plotResult(x, pred1)
- DBSCAN 사용
dm = DBSCAN(eps=0.2, min_samples=5, metric = 'euclidean')
pred2 = dm.fit_predict(x)
print(pred2)
plotResult(x, pred2)
'BACK END > Deep Learning' 카테고리의 다른 글
[딥러닝] TensorFlow (0) | 2021.03.22 |
---|---|
[딥러닝] TensorFlow 환경설정 (0) | 2021.03.22 |
[딥러닝] k-means (0) | 2021.03.22 |
[딥러닝] 클러스터링 (0) | 2021.03.19 |
[딥러닝] Neural Network (0) | 2021.03.19 |