Я уже проверил скикит-вопросы DBSCAN (которые очень старые), но мой код выдает ошибку:
DBSCAN () получил неожиданный аргумент eps
Ввод не мой фактвведите только тестовые значения, но у меня есть эта проблема сейчас. Буду признателен, если вы поможете
from sklearn.cluster import DBSCAN
import numpy as np
def clusterCenter(ll:list):
x=0
y=0
for el in ll:
x=x+el[0]
y=y+el[1]
x=x/len(ll)
y=y/len(ll)
return (x,y)
def printCoords(clist:list):
for el in clist:
x,y = el
print( str(x)+", "+str(y) )
def DBSCAN(X:np.array, max_distance:float, min_nodes_in_cluster:int):
clusterCenters=[]
dbscan = DBSCAN(eps=max_distance, min_samples=min_nodes_in_cluster,metric="euclidian").fit(X)
alllabels=dbscan.labels_
#getting the points in each cluster by using a dictionary
num=0
dict={}
for el in alllabels:
if dict.get(el) is None:
somearr=[]
somearr.append(X[num])
dict[el]=somearr
else:
dict[el].append(X[num])
num=num+1
#print all cluster centers for each cluster
for key in dict:
x,y=clusterCenter(dict[key])
clusterCenters.append((x,y))
return clusterCenters
X = np.array([[1, 2], [2, 2], [2, 3],[8, 7], [8, 8], [25, 80]])
cclist=DBSCAN(X,1.3,5)
printCoords(cclist)