Я пытался построить график кластеризации DBSCAN
, но обнаружил ошибку:
AttributeError: 'DBSCAN' object has no attribute 'labels'
Код:
from sklearn.cluster import DBSCAN
model = DBSCAN(eps=3)
X = dataset.data
model.fit(X)
df=pd.DataFrame(iris['data'])
df.head()
print(model)
%matplotlib inline
# Visualize the results
import matplotlib.pyplot as plt
X = dataset.data
y_kmeans = model.fit_predict(X) # this give the cluster number of the nearest centroid
# scatter plot the petal length (column 2), petal width (column 3)
plt.scatter(X[:, 2], X[:, 3], c=y_kmeans, s=50, cmap='viridis')
# show centroid centres as grey circle opacity 50%
centers = model.labels
plt.scatter(centers[:, 2], centers[:, 3], c='black', s=200, alpha=0.5)
Любые предложения или альтернативы были бы полезны!