Neuron 101

Learning without labels / Density-based clustering

Türkçe

Plate70

Unit 7 · Topic 5 of 6

Density-based clustering

Medium, 9 min, 7 steps

020406080100120140160180200020406080100east, metresnorth, metres
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Data

Two paths in a park

The positions of walkers in a park were recorded, the axes are in metres. The points line up along two curving footpaths, and a few points are off the paths. You can pick out the two paths by eye at once.

Open in Colab
  1. eps, minpts = 16.0, 3
  2. def komsu(i):
  3. return [j for j in range(n)
  4. if math.dist(P[i], P[j])
  5. <= eps]
  6. cekirdek = [len(komsu(i)) >= minpts
  7. for i in range(n)]
  8. etiket = [-1] * n
  9. def buyut(i, c):
  10. etiket[i] = c
  11. kuyruk = [i]
  12. while kuyruk:
  13. j = kuyruk.pop(0)
  14. for q in komsu(j):
  15. if etiket[q] < 0:
  16. etiket[q] = c
  17. if cekirdek[q]:
  18. kuyruk.append(q)
  19. c = 0
  20. for i in range(n):
  21. if cekirdek[i] and etiket[i] < 0:
  22. buyut(i, c)
  23. c += 1
  24. print(c, etiket)
eps
16
minPts
3
no
8
komsu
3
kume
2
yanlis
7
cekirdek
27
gurultu
3
sinir
3