Alterna · learning material

06.5 Groups without ready correct responses

We're gonna try to distribute the dots to the nearest centres and count the centres as middle coordinates, which is group search, not mark training.

What this material covers

Content and key concepts

On the previous page, how to compare errors of different types.
We're gonna try to distribute the dots to the nearest centres and count the centres as middle coordinates, which is group search, not mark training.
The selection of straight lines and the division of points makes it possible to see the learning process on simple data. Verification answers do not participate in the corrections.
Для изменения рисунка включитеJavaScript; расчёт и теория доступны далее.
Set up centres, then count them.
K-means only gets the sign vectors and the number of clusters.K. It minimizes the sum of squares of distances to selected centroids. IDs clusters are unknown semantic classes.
J
=
∑
i
∥
x
i
−
μ
c
i
∥
2
2
,
c
i
=
arg
⁡
min
⁡
k
∥
x
i
−
μ
k
∥
2
2
,
μ
k
=
1
n
k
∑
i
:
c
i
=
k
x
i
.
J=\sum_i\|x_i-\mu_{c_i}\|_2^2,\quad
c_i=\arg\min_k\|x_i-\mu_k\|_2^2,\quad
\mu_k=\frac1{n_k}\sum_{i:c_i=k}x_i.
J
=
i
∑
​
∥
x
i
​
−
μ
c
i
​
​
∥
2
2
​
,
c
i
​
=
ar
g
k
min
​
∥
x
i
​
−
μ
k
​
∥
2
2
​
,
μ
k
​
=
n
k
​
1
​
i
:
c
i
​
=
k
∑
​
x
i
​
.
At fixed centres, the closest choice is to minimize each contribution. With fixed signings, the minimum center is derived from derivative squared.
arithmetic
, not geometric mean.
In the lab, six points, two centres, and the final sequence assignment/update. Tis choose a smaller index. If the cluster is empty, its old center is retained with explanation; random reinitiation would be a different policy. Once updated, labels are re-calculated for new centres so that the indicated inertia does not refer to old geometry.
Research.
Compare divided and identical initial centres. Why can the first tie-break leave a single claster empty? Why can't you interpret the number 0 as a "bad" class? Decreasing obprojective does not guarantee the global optimum and meaningful utility of clustering. The magnitude of the signs changes distances and outcomes, so pre-processing is part of the method.
points=[[0,0],[2,0]]
center=[sum(row[j] for row in points)/len(points) for j in range(2)]
inertia=sum(sum((a-b)**2 for a,b in zip(row,center)) for row in points)
assert center==[1,0] and inertia==2
The code repeats the operations just taken care of.
Completely checked Python-example Chapter
Available with a separate file; the short piece shown does not replace its implementation.
The sum of squares gives the average coordinates.
What are the directions of the data that are important to the figure? How does this question continue?
Python examples of Chapter 06
Academic base

Textbook contents map