Neuron 101

Learning without labels / Unlabeled data

Türkçe

Plate66

Unit 7 · Topic 1 of 6

Unlabeled data

Easy, 7 min, 7 steps

024681012141618200246810weekday visitsweekend visits
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Data

25 customers, no labels

A café counted how often each customer came in one month: weekday visits across, weekend visits up. In unit 4 every day had a class; here there is none. Nobody wrote which customer belongs to which group; the algorithm only has these 25 points.

Open in Colab
  1. import math
  2. def uzak(i, j):
  3. return math.dist(M[i], M[j])
  4. a, b = 2 - 1, 3 - 1
  5. print(uzak(a, b))
  6. r = 2.0
  7. yakin = [j for j in range(n)
  8. if uzak(a, j) <= r]
  9. print(len(yakin) - 1)
  10. grup = list(range(n))
  11. def kok(i):
  12. while grup[i] != i:
  13. i = grup[i]
  14. return i
  15. for i in range(n):
  16. for j in range(i):
  17. if uzak(i, j) <= r:
  18. grup[kok(i)] = kok(j)
  19. print(len({kok(i) for i in range(n)}))
  20. def yalnizlik(i):
  21. d = [uzak(i, j) for j in range(n)
  22. if j != i]
  23. return min(d)
  24. en = max(range(n), key=yalnizlik)
  25. print(en + 1)
a
2
b
3
r
2
komsu
3
grup
4
renkli
3
yalnizNo
13
n
25