<s>
k-means	B-Algorithm
clustering	I-Algorithm
is	O
a	O
method	O
of	O
vector	B-Algorithm
quantization	I-Algorithm
,	O
originally	O
from	O
signal	O
processing	O
,	O
that	O
aims	O
to	O
partition	O
n	O
observations	O
into	O
k	O
clusters	O
in	O
which	O
each	O
observation	O
belongs	O
to	O
the	O
cluster	O
with	O
the	O
nearest	O
mean	O
(	O
cluster	O
centers	O
or	O
cluster	O
centroid	O
)	O
,	O
serving	O
as	O
a	O
prototype	O
of	O
the	O
cluster	O
.	O
</s>
<s>
This	O
results	O
in	O
a	O
partitioning	O
of	O
the	O
data	O
space	O
into	O
Voronoi	B-Architecture
cells	I-Architecture
.	O
</s>
<s>
k-means	B-Algorithm
clustering	I-Algorithm
minimizes	O
within-cluster	O
variances	O
(	O
squared	O
Euclidean	O
distances	O
)	O
,	O
but	O
not	O
regular	O
Euclidean	O
distances	O
,	O
which	O
would	O
be	O
the	O
more	O
difficult	O
Weber	O
problem	O
:	O
the	O
mean	O
optimizes	O
squared	O
errors	O
,	O
whereas	O
only	O
the	O
geometric	B-General_Concept
median	I-General_Concept
minimizes	O
Euclidean	O
distances	O
.	O
</s>
<s>
For	O
instance	O
,	O
better	O
Euclidean	O
solutions	O
can	O
be	O
found	O
using	O
k-medians	B-Algorithm
and	O
k-medoids	B-Algorithm
.	O
</s>
<s>
The	O
problem	O
is	O
computationally	O
difficult	O
(	O
NP-hard	O
)	O
;	O
however	O
,	O
efficient	O
heuristic	B-Algorithm
algorithms	I-Algorithm
converge	O
quickly	O
to	O
a	O
local	O
optimum	O
.	O
</s>
<s>
These	O
are	O
usually	O
similar	O
to	O
the	O
expectation-maximization	B-Algorithm
algorithm	I-Algorithm
for	O
mixtures	O
of	O
Gaussian	O
distributions	O
via	O
an	O
iterative	O
refinement	O
approach	O
employed	O
by	O
both	O
k-means	B-Algorithm
and	O
Gaussian	O
mixture	O
modeling	O
.	O
</s>
<s>
They	O
both	O
use	O
cluster	O
centers	O
to	O
model	O
the	O
data	O
;	O
however	O
,	O
k-means	B-Algorithm
clustering	I-Algorithm
tends	O
to	O
find	O
clusters	O
of	O
comparable	O
spatial	O
extent	O
,	O
while	O
the	O
Gaussian	O
mixture	O
model	O
allows	O
clusters	O
to	O
have	O
different	O
shapes	O
.	O
</s>
<s>
The	O
unsupervised	O
k-means	B-Algorithm
algorithm	I-Algorithm
has	O
a	O
loose	O
relationship	O
to	O
the	O
k-nearest	B-General_Concept
neighbor	I-General_Concept
classifier	O
,	O
a	O
popular	O
supervised	B-General_Concept
machine	I-General_Concept
learning	I-General_Concept
technique	O
for	O
classification	O
that	O
is	O
often	O
confused	O
with	O
k-means	B-Algorithm
due	O
to	O
the	O
name	O
.	O
</s>
<s>
Applying	O
the	O
1-nearest	O
neighbor	O
classifier	O
to	O
the	O
cluster	O
centers	O
obtained	O
by	O
k-means	B-Algorithm
classifies	O
new	O
data	O
into	O
the	O
existing	O
clusters	O
.	O
</s>
<s>
This	O
is	O
known	O
as	O
nearest	B-Algorithm
centroid	I-Algorithm
classifier	I-Algorithm
or	O
Rocchio	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
Given	O
a	O
set	O
of	O
observations	O
(	O
x1	O
,	O
x2	O
,	O
...	O
,	O
xn	O
)	O
,	O
where	O
each	O
observation	O
is	O
a	O
d-dimensional	O
real	O
vector	O
,	O
k-means	B-Algorithm
clustering	I-Algorithm
aims	O
to	O
partition	O
the	O
n	O
observations	O
into	O
k	O
( ≤	O
n	O
)	O
sets	O
S	O
=	O
{	O
S1	O
,	O
S2	O
,	O
...	O
,	O
Sk}	O
so	O
as	O
to	O
minimize	O
the	O
within-cluster	O
sum	O
of	O
squares	O
(	O
WCSS	O
)	O
(	O
i.e.	O
</s>
<s>
The	O
term	O
"	O
k-means	B-Algorithm
"	O
was	O
first	O
used	O
by	O
James	O
MacQueen	O
in	O
1967	O
,	O
though	O
the	O
idea	O
goes	O
back	O
to	O
Hugo	O
Steinhaus	O
in	O
1956	O
.	O
</s>
<s>
The	O
standard	O
algorithm	O
was	O
first	O
proposed	O
by	O
Stuart	O
Lloyd	O
of	O
Bell	O
Labs	O
in	O
1957	O
as	O
a	O
technique	O
for	O
pulse-code	B-Algorithm
modulation	I-Algorithm
,	O
although	O
it	O
was	O
not	O
published	O
as	O
a	O
journal	O
article	O
until	O
1982	O
.	O
</s>
<s>
Due	O
to	O
its	O
ubiquity	O
,	O
it	O
is	O
often	O
called	O
"	O
the	O
k-means	B-Algorithm
algorithm	I-Algorithm
"	O
;	O
it	O
is	O
also	O
referred	O
to	O
as	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
particularly	O
in	O
the	O
computer	O
science	O
community	O
.	O
</s>
<s>
It	O
is	O
sometimes	O
also	O
referred	O
to	O
as	O
"	O
naïve	O
k-means	B-Algorithm
"	O
,	O
because	O
there	O
exist	O
much	O
faster	O
alternatives	O
.	O
</s>
<s>
Given	O
an	O
initial	O
set	O
of	O
k	B-Algorithm
means	I-Algorithm
m1(1 )	O
,	O
...	O
,	O
mk(1 )	O
(	O
see	O
below	O
)	O
,	O
the	O
algorithm	O
proceeds	O
by	O
alternating	O
between	O
two	O
steps	O
:	O
</s>
<s>
(	O
Mathematically	O
,	O
this	O
means	O
partitioning	O
the	O
observations	O
according	O
to	O
the	O
Voronoi	B-Architecture
diagram	I-Architecture
generated	O
by	O
the	O
means	O
.	O
)	O
</s>
<s>
Various	O
modifications	O
of	O
k-means	B-Algorithm
such	O
as	O
spherical	O
k-means	B-Algorithm
and	O
k-medoids	B-Algorithm
have	O
been	O
proposed	O
to	O
allow	O
using	O
other	O
distance	O
measures	O
.	O
</s>
<s>
According	O
to	O
Hamerly	O
et	O
al.	O
,	O
the	O
Random	O
Partition	O
method	O
is	O
generally	O
preferable	O
for	O
algorithms	O
such	O
as	O
the	O
k-harmonic	O
means	O
and	O
fuzzy	O
k-means	B-Algorithm
.	O
</s>
<s>
For	O
expectation	B-Algorithm
maximization	I-Algorithm
and	O
standard	O
k-means	B-Algorithm
algorithms	I-Algorithm
,	O
the	O
Forgy	O
method	O
of	O
initialization	O
is	O
preferable	O
.	O
</s>
<s>
A	O
comprehensive	O
study	O
by	O
Celebi	O
et	O
al.	O
,	O
however	O
,	O
found	O
that	O
popular	O
initialization	O
methods	O
such	O
as	O
Forgy	O
,	O
Random	O
Partition	O
,	O
and	O
Maximin	O
often	O
perform	O
poorly	O
,	O
whereas	O
Bradley	O
and	O
Fayyad	O
's	O
approach	O
performs	O
"	O
consistently	O
"	O
in	O
"	O
the	O
best	O
group	O
"	O
and	O
k-means	B-Algorithm
++	I-Algorithm
performs	O
"	O
generally	O
well	O
"	O
.	O
</s>
<s>
These	O
point	O
sets	O
do	O
not	O
seem	O
to	O
arise	O
in	O
practice	O
:	O
this	O
is	O
corroborated	O
by	O
the	O
fact	O
that	O
the	O
smoothed	O
running	O
time	O
of	O
k-means	B-Algorithm
is	O
polynomial	O
.	O
</s>
<s>
The	O
"	O
assignment	O
"	O
step	O
is	O
referred	O
to	O
as	O
the	O
"	O
expectation	O
step	O
"	O
,	O
while	O
the	O
"	O
update	O
step	O
"	O
is	O
a	O
maximization	O
step	O
,	O
making	O
this	O
algorithm	O
a	O
variant	O
of	O
the	O
generalized	O
expectation-maximization	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
Finding	O
the	O
optimal	O
solution	O
to	O
the	O
k-means	B-Algorithm
clustering	I-Algorithm
problem	O
for	O
observations	O
in	O
d	O
dimensions	O
is	O
:	O
</s>
<s>
Thus	O
,	O
a	O
variety	O
of	O
heuristic	B-Algorithm
algorithms	I-Algorithm
such	O
as	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
given	O
above	O
are	O
generally	O
used	O
.	O
</s>
<s>
The	O
running	O
time	O
of	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
(	O
and	O
most	O
variants	O
)	O
is	O
,	O
where	O
:	O
</s>
<s>
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
therefore	O
often	O
considered	O
to	O
be	O
of	O
"	O
linear	O
"	O
complexity	O
in	O
practice	O
,	O
although	O
it	O
is	O
in	O
the	O
worst	B-General_Concept
case	I-General_Concept
superpolynomial	O
when	O
performed	O
until	O
convergence	O
.	O
</s>
<s>
In	O
the	O
worst-case	O
,	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
needs	O
iterations	O
,	O
so	O
that	O
the	O
worst-case	B-General_Concept
complexity	I-General_Concept
of	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
superpolynomial	O
.	O
</s>
<s>
Lloyd	O
's	O
k-means	B-Algorithm
algorithm	I-Algorithm
has	O
polynomial	O
smoothed	O
running	O
time	O
.	O
</s>
<s>
For	O
example	O
,	O
it	O
is	O
shown	O
that	O
the	O
running	O
time	O
of	O
k-means	B-Algorithm
algorithm	I-Algorithm
is	O
bounded	O
by	O
for	O
points	O
in	O
an	O
integer	O
lattice	O
.	O
</s>
<s>
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
the	O
standard	O
approach	O
for	O
this	O
problem	O
.	O
</s>
<s>
Some	O
implementations	O
use	O
caching	O
and	O
the	O
triangle	O
inequality	O
in	O
order	O
to	O
create	O
bounds	O
and	O
accelerate	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
k-medians	B-Algorithm
clustering	I-Algorithm
uses	O
the	O
median	O
in	O
each	O
dimension	O
instead	O
of	O
the	O
mean	O
,	O
and	O
this	O
way	O
minimizes	O
norm	O
(	O
Taxicab	O
geometry	O
)	O
.	O
</s>
<s>
k-medoids	B-Algorithm
(	O
also	O
:	O
Partitioning	B-Algorithm
Around	I-Algorithm
Medoids	I-Algorithm
,	O
PAM	O
)	O
uses	O
the	O
medoid	B-Algorithm
instead	O
of	O
the	O
mean	O
,	O
and	O
this	O
way	O
minimizes	O
the	O
sum	O
of	O
distances	O
for	O
arbitrary	O
distance	O
functions	O
.	O
</s>
<s>
Fuzzy	O
C-Means	O
Clustering	O
is	O
a	O
soft	O
version	O
of	O
k-means	B-Algorithm
,	O
where	O
each	O
data	O
point	O
has	O
a	O
fuzzy	O
degree	O
of	O
belonging	O
to	O
each	O
cluster	O
.	O
</s>
<s>
Gaussian	O
mixture	O
models	O
trained	O
with	O
expectation-maximization	B-Algorithm
algorithm	I-Algorithm
(	O
EM	B-Algorithm
algorithm	I-Algorithm
)	O
maintains	O
probabilistic	O
assignments	O
to	O
clusters	O
,	O
instead	O
of	O
deterministic	O
assignments	O
,	O
and	O
multivariate	O
Gaussian	O
distributions	O
instead	O
of	O
means	O
.	O
</s>
<s>
k-means	B-Algorithm
++	I-Algorithm
chooses	O
initial	O
centers	O
in	O
a	O
way	O
that	O
gives	O
a	O
provable	O
upper	O
bound	O
on	O
the	O
WCSS	O
objective	O
.	O
</s>
<s>
The	O
filtering	O
algorithm	O
uses	O
kd-trees	B-Data_Structure
to	O
speed	O
up	O
each	O
k-means	B-Algorithm
step	O
.	O
</s>
<s>
Some	O
methods	O
attempt	O
to	O
speed	O
up	O
each	O
k-means	B-Algorithm
step	O
using	O
the	O
triangle	O
inequality	O
.	O
</s>
<s>
The	O
Spherical	O
k-means	B-Algorithm
clustering	I-Algorithm
algorithm	I-Algorithm
is	O
suitable	O
for	O
textual	O
data	O
.	O
</s>
<s>
Hierarchical	O
variants	O
such	O
as	O
Bisecting	O
k-means	B-Algorithm
,	O
X-means	O
clustering	O
and	O
G-means	O
clustering	O
repeatedly	O
split	O
clusters	O
to	O
build	O
a	O
hierarchy	O
,	O
and	O
can	O
also	O
try	O
to	O
automatically	O
determine	O
the	O
optimal	O
number	O
of	O
clusters	O
in	O
a	O
dataset	O
.	O
</s>
<s>
Internal	O
cluster	O
evaluation	O
measures	O
such	O
as	O
cluster	O
silhouette	O
can	O
be	O
helpful	O
at	O
determining	B-Algorithm
the	I-Algorithm
number	I-Algorithm
of	I-Algorithm
clusters	I-Algorithm
.	O
</s>
<s>
Minkowski	O
weighted	O
k-means	B-Algorithm
automatically	O
calculates	O
cluster	O
specific	O
feature	O
weights	O
,	O
supporting	O
the	O
intuitive	O
idea	O
that	O
a	O
feature	O
may	O
have	O
different	O
degrees	O
of	O
relevance	O
at	O
different	O
features	O
.	O
</s>
<s>
Mini-batch	O
k-means	B-Algorithm
:	O
k-means	B-Algorithm
variation	O
using	O
"	O
mini	O
batch	O
"	O
samples	O
for	O
data	O
sets	O
that	O
do	O
not	O
fit	O
into	O
memory	O
.	O
</s>
<s>
Hartigan	O
and	O
Wong	O
's	O
method	O
provides	O
a	O
variation	O
of	O
k-means	B-Algorithm
algorithm	I-Algorithm
which	O
progresses	O
towards	O
a	O
local	O
minimum	O
of	O
the	O
minimum	O
sum-of-squares	O
problem	O
with	O
different	O
solution	O
updates	O
.	O
</s>
<s>
The	O
method	O
is	O
a	O
local	B-Algorithm
search	I-Algorithm
that	O
iteratively	O
attempts	O
to	O
relocate	O
a	O
sample	O
into	O
a	O
different	O
cluster	O
as	O
long	O
as	O
this	O
process	O
improves	O
the	O
objective	O
function	O
.	O
</s>
<s>
In	O
a	O
similar	O
way	O
as	O
the	O
classical	O
k-means	B-Algorithm
,	O
the	O
approach	O
remains	O
a	O
heuristic	B-Algorithm
since	O
it	O
does	O
not	O
necessarily	O
guarantee	O
that	O
the	O
final	O
solution	O
is	O
globally	O
optimum	O
.	O
</s>
<s>
The	O
classical	O
k-means	B-Algorithm
algorithm	I-Algorithm
and	O
its	O
variations	O
are	O
known	O
to	O
only	O
converge	O
to	O
local	O
minima	O
of	O
the	O
minimum-sum-of-squares	O
clustering	O
problem	O
defined	O
as	O
Many	O
studies	O
have	O
attempted	O
to	O
improve	O
the	O
convergence	O
behavior	O
of	O
the	O
algorithm	O
and	O
maximize	O
the	O
chances	O
of	O
attaining	O
the	O
global	O
optimum	O
(	O
or	O
at	O
least	O
,	O
local	O
minima	O
of	O
better	O
quality	O
)	O
.	O
</s>
<s>
More	O
recently	O
,	O
global	O
optimization	O
algorithms	O
based	O
on	O
branch-and-bound	B-Algorithm
and	O
semidefinite	O
programming	O
have	O
produced	O
‘’	O
provenly	O
optimal’’	O
solutions	O
for	O
datasets	O
with	O
up	O
to	O
4,177	O
entities	O
and	O
20,531	O
features	O
.	O
</s>
<s>
As	O
expected	O
,	O
due	O
to	O
the	O
NP-hardness	O
of	O
the	O
subjacent	O
optimization	O
problem	O
,	O
the	O
computational	O
time	O
of	O
optimal	O
algorithms	O
for	O
K-means	B-Algorithm
quickly	O
increases	O
beyond	O
this	O
size	O
.	O
</s>
<s>
Optimal	O
solutions	O
for	O
small	O
-	O
and	O
medium-scale	O
still	O
remain	O
valuable	O
as	O
a	O
benchmark	O
tool	O
,	O
to	O
evaluate	O
the	O
quality	O
of	O
other	O
heuristics	B-Algorithm
.	O
</s>
<s>
To	O
find	O
high-quality	O
local	O
minima	O
within	O
a	O
controlled	O
computational	O
time	O
but	O
without	O
optimality	O
guarantees	O
,	O
other	O
works	O
have	O
explored	O
metaheuristics	B-Algorithm
and	O
other	O
global	O
optimization	O
techniques	O
,	O
e.g.	O
,	O
based	O
on	O
incremental	O
approaches	O
and	O
convex	O
optimization	O
,	O
random	O
swaps	O
(	O
i.e.	O
,	O
iterated	B-Algorithm
local	I-Algorithm
search	I-Algorithm
)	O
,	O
variable	B-Algorithm
neighborhood	I-Algorithm
search	I-Algorithm
and	O
genetic	B-Algorithm
algorithms	I-Algorithm
.	O
</s>
<s>
Three	O
key	O
features	O
of	O
k-means	B-Algorithm
that	O
make	O
it	O
efficient	O
are	O
often	O
regarded	O
as	O
its	O
biggest	O
drawbacks	O
:	O
</s>
<s>
That	O
is	O
why	O
,	O
when	O
performing	O
k-means	B-Algorithm
,	O
it	O
is	O
important	O
to	O
run	O
diagnostic	O
checks	O
for	O
determining	B-Algorithm
the	I-Algorithm
number	I-Algorithm
of	I-Algorithm
clusters	I-Algorithm
in	I-Algorithm
the	I-Algorithm
data	I-Algorithm
set	I-Algorithm
.	O
</s>
<s>
A	O
key	O
limitation	O
of	O
k-means	B-Algorithm
is	O
its	O
cluster	O
model	O
.	O
</s>
<s>
When	O
for	O
example	O
applying	O
k-means	B-Algorithm
with	O
a	O
value	O
of	O
onto	O
the	O
well-known	O
Iris	B-Language
flower	I-Language
data	I-Language
set	I-Language
,	O
the	O
result	O
often	O
fails	O
to	O
separate	O
the	O
three	O
Iris	O
species	O
contained	O
in	O
the	O
data	O
set	O
.	O
</s>
<s>
As	O
with	O
any	O
other	O
clustering	O
algorithm	O
,	O
the	O
k-means	B-Algorithm
result	O
makes	O
assumptions	O
that	O
the	O
data	O
satisfy	O
certain	O
criteria	O
.	O
</s>
<s>
The	O
result	O
of	O
k-means	B-Algorithm
can	O
be	O
seen	O
as	O
the	O
Voronoi	B-Architecture
cells	I-Architecture
of	O
the	O
cluster	O
means	O
.	O
</s>
<s>
The	O
Gaussian	O
models	O
used	O
by	O
the	O
expectation-maximization	B-Algorithm
algorithm	I-Algorithm
(	O
arguably	O
a	O
generalization	O
of	O
k-means	B-Algorithm
)	O
are	O
more	O
flexible	O
by	O
having	O
both	O
variances	O
and	O
covariances	O
.	O
</s>
<s>
The	O
EM	O
result	O
is	O
thus	O
able	O
to	O
accommodate	O
clusters	O
of	O
variable	O
size	O
much	O
better	O
than	O
k-means	B-Algorithm
as	O
well	O
as	O
correlated	O
clusters	O
(	O
not	O
in	O
this	O
example	O
)	O
.	O
</s>
<s>
K-means	B-Algorithm
is	O
closely	O
related	O
to	O
nonparametric	O
Bayesian	O
modeling	O
.	O
</s>
<s>
k-means	B-Algorithm
clustering	I-Algorithm
is	O
rather	O
easy	O
to	O
apply	O
to	O
even	O
large	O
data	O
sets	O
,	O
particularly	O
when	O
using	O
heuristics	B-Algorithm
such	O
as	O
Lloyd	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
It	O
has	O
been	O
successfully	O
used	O
in	O
market	O
segmentation	B-Algorithm
,	O
computer	B-Application
vision	I-Application
,	O
and	O
astronomy	O
among	O
many	O
other	O
domains	O
.	O
</s>
<s>
k-means	B-Algorithm
originates	O
from	O
signal	O
processing	O
,	O
and	O
still	O
finds	O
use	O
in	O
this	O
domain	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
computer	O
graphics	O
,	O
color	B-Algorithm
quantization	I-Algorithm
is	O
the	O
task	O
of	O
reducing	O
the	O
color	B-Data_Structure
palette	I-Data_Structure
of	O
an	O
image	O
to	O
a	O
fixed	O
number	O
of	O
colors	O
k	O
.	O
The	O
k-means	B-Algorithm
algorithm	I-Algorithm
can	O
easily	O
be	O
used	O
for	O
this	O
task	O
and	O
produces	O
competitive	O
results	O
.	O
</s>
<s>
A	O
use	O
case	O
for	O
this	O
approach	O
is	O
image	B-Algorithm
segmentation	I-Algorithm
.	O
</s>
<s>
Other	O
uses	O
of	O
vector	B-Algorithm
quantization	I-Algorithm
include	O
non-random	O
sampling	O
,	O
as	O
k-means	B-Algorithm
can	O
easily	O
be	O
used	O
to	O
choose	O
k	O
different	O
but	O
prototypical	O
objects	O
from	O
a	O
large	O
data	O
set	O
for	O
further	O
analysis	O
.	O
</s>
<s>
In	O
cluster	O
analysis	O
,	O
the	O
k-means	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
used	O
to	O
partition	O
the	O
input	O
data	O
set	O
into	O
k	O
partitions	O
(	O
clusters	O
)	O
.	O
</s>
<s>
However	O
,	O
the	O
pure	O
k-means	B-Algorithm
algorithm	I-Algorithm
is	O
not	O
very	O
flexible	O
,	O
and	O
as	O
such	O
is	O
of	O
limited	O
use	O
(	O
except	O
for	O
when	O
vector	B-Algorithm
quantization	I-Algorithm
as	O
above	O
is	O
actually	O
the	O
desired	O
use	O
case	O
)	O
.	O
</s>
<s>
k-means	B-Algorithm
clustering	I-Algorithm
has	O
been	O
used	O
as	O
a	O
feature	B-General_Concept
learning	I-General_Concept
(	O
or	O
dictionary	B-General_Concept
learning	I-General_Concept
)	O
step	O
,	O
in	O
either	O
(	O
semi	B-General_Concept
-	I-General_Concept
)	O
supervised	B-General_Concept
learning	I-General_Concept
or	O
unsupervised	B-General_Concept
learning	I-General_Concept
.	O
</s>
<s>
The	O
basic	O
approach	O
is	O
first	O
to	O
train	O
a	O
k-means	B-Algorithm
clustering	I-Algorithm
representation	O
,	O
using	O
the	O
input	O
training	O
data	O
(	O
which	O
need	O
not	O
be	O
labelled	O
)	O
.	O
</s>
<s>
Alternatively	O
,	O
transforming	O
the	O
sample-cluster	O
distance	O
through	O
a	O
Gaussian	B-Algorithm
RBF	I-Algorithm
,	O
obtains	O
the	O
hidden	O
layer	O
of	O
a	O
radial	B-Algorithm
basis	I-Algorithm
function	I-Algorithm
network	I-Algorithm
.	O
</s>
<s>
This	O
use	O
of	O
k-means	B-Algorithm
has	O
been	O
successfully	O
combined	O
with	O
simple	O
,	O
linear	B-General_Concept
classifiers	I-General_Concept
for	O
semi-supervised	B-General_Concept
learning	I-General_Concept
in	O
NLP	B-Language
(	O
specifically	O
for	O
named	B-General_Concept
entity	I-General_Concept
recognition	I-General_Concept
)	O
and	O
in	O
computer	B-Application
vision	I-Application
.	O
</s>
<s>
On	O
an	O
object	O
recognition	O
task	O
,	O
it	O
was	O
found	O
to	O
exhibit	O
comparable	O
performance	O
with	O
more	O
sophisticated	O
feature	B-General_Concept
learning	I-General_Concept
approaches	O
such	O
as	O
autoencoders	B-Algorithm
and	O
restricted	B-Algorithm
Boltzmann	I-Algorithm
machines	I-Algorithm
.	O
</s>
<s>
The	O
slow	O
"	O
standard	O
algorithm	O
"	O
for	O
k-means	B-Algorithm
clustering	I-Algorithm
,	O
and	O
its	O
associated	O
expectation-maximization	B-Algorithm
algorithm	I-Algorithm
,	O
is	O
a	O
special	O
case	O
of	O
a	O
Gaussian	O
mixture	O
model	O
,	O
specifically	O
,	O
the	O
limiting	O
case	O
when	O
fixing	O
all	O
covariances	O
to	O
be	O
diagonal	O
,	O
equal	O
and	O
have	O
infinitesimal	O
small	O
variance	O
.	O
</s>
<s>
Instead	O
of	O
small	O
variances	O
,	O
a	O
hard	O
cluster	O
assignment	O
can	O
also	O
be	O
used	O
to	O
show	O
another	O
equivalence	O
of	O
k-means	B-Algorithm
clustering	I-Algorithm
to	O
a	O
special	O
case	O
of	O
"	O
hard	O
"	O
Gaussian	O
mixture	O
modelling	O
.	O
</s>
<s>
This	O
does	O
not	O
mean	O
that	O
it	O
is	O
efficient	O
to	O
use	O
Gaussian	O
mixture	O
modelling	O
to	O
compute	O
k-means	B-Algorithm
,	O
but	O
just	O
that	O
there	O
is	O
a	O
theoretical	O
relationship	O
,	O
and	O
that	O
Gaussian	O
mixture	O
modelling	O
can	O
be	O
interpreted	O
as	O
a	O
generalization	O
of	O
k-means	B-Algorithm
;	O
on	O
the	O
contrary	O
,	O
it	O
has	O
been	O
suggested	O
to	O
use	O
k-means	B-Algorithm
clustering	I-Algorithm
to	O
find	O
starting	O
points	O
for	O
Gaussian	O
mixture	O
modelling	O
on	O
difficult	O
data	O
.	O
</s>
<s>
Another	O
generalization	O
of	O
the	O
k-means	B-Algorithm
algorithm	I-Algorithm
is	O
the	O
k-SVD	O
algorithm	O
,	O
which	O
estimates	O
data	O
points	O
as	O
a	O
sparse	O
linear	O
combination	O
of	O
"	O
codebook	O
vectors	O
"	O
.	O
</s>
<s>
k-means	B-Algorithm
corresponds	O
to	O
the	O
special	O
case	O
of	O
using	O
a	O
single	O
codebook	O
vector	O
,	O
with	O
a	O
weight	O
of	O
1	O
.	O
</s>
<s>
The	O
intuition	O
is	O
that	O
k-means	B-Algorithm
describe	O
spherically	O
shaped	O
(	O
ball-like	O
)	O
clusters	O
.	O
</s>
<s>
Well-separated	O
clusters	O
are	O
effectively	O
modelled	O
by	O
ball-shaped	O
clusters	O
and	O
thus	O
discovered	O
by	O
k-means	B-Algorithm
.	O
</s>
<s>
k-means	B-Algorithm
should	O
not	O
be	O
expected	O
to	O
do	O
well	O
on	O
this	O
data	O
.	O
</s>
<s>
Basic	O
mean	B-Algorithm
shift	I-Algorithm
clustering	O
algorithms	O
maintain	O
a	O
set	O
of	O
data	O
points	O
the	O
same	O
size	O
as	O
the	O
input	O
data	O
set	O
.	O
</s>
<s>
By	O
contrast	O
,	O
k-means	B-Algorithm
restricts	O
this	O
updated	O
set	O
to	O
k	O
points	O
usually	O
much	O
less	O
than	O
the	O
number	O
of	O
points	O
in	O
the	O
input	O
data	O
set	O
,	O
and	O
replaces	O
each	O
point	O
in	O
this	O
set	O
by	O
the	O
mean	O
of	O
all	O
points	O
in	O
the	O
input	O
set	O
that	O
are	O
closer	O
to	O
that	O
point	O
than	O
any	O
other	O
(	O
e.g.	O
</s>
<s>
within	O
the	O
Voronoi	B-Architecture
partition	I-Architecture
of	O
each	O
updating	O
point	O
)	O
.	O
</s>
<s>
A	O
mean	B-Algorithm
shift	I-Algorithm
algorithm	O
that	O
is	O
similar	O
then	O
to	O
k-means	B-Algorithm
,	O
called	O
likelihood	O
mean	B-Algorithm
shift	I-Algorithm
,	O
replaces	O
the	O
set	O
of	O
points	O
undergoing	O
replacement	O
by	O
the	O
mean	O
of	O
all	O
points	O
in	O
the	O
input	O
set	O
that	O
are	O
within	O
a	O
given	O
distance	O
of	O
the	O
changing	O
set	O
.	O
</s>
<s>
One	O
of	O
the	O
advantages	O
of	O
mean	B-Algorithm
shift	I-Algorithm
over	O
k-means	B-Algorithm
is	O
that	O
the	O
number	O
of	O
clusters	O
is	O
not	O
pre-specified	O
,	O
because	O
mean	B-Algorithm
shift	I-Algorithm
is	O
likely	O
to	O
find	O
only	O
a	O
few	O
clusters	O
if	O
only	O
a	O
small	O
number	O
exist	O
.	O
</s>
<s>
However	O
,	O
mean	B-Algorithm
shift	I-Algorithm
can	O
be	O
much	O
slower	O
than	O
k-means	B-Algorithm
,	O
and	O
still	O
requires	O
selection	O
of	O
a	O
bandwidth	O
parameter	O
.	O
</s>
<s>
Mean	B-Algorithm
shift	I-Algorithm
has	O
soft	O
variants	O
.	O
</s>
<s>
Under	O
sparsity	O
assumptions	O
and	O
when	O
input	O
data	O
is	O
pre-processed	O
with	O
the	O
whitening	B-Algorithm
transformation	I-Algorithm
,	O
k-means	B-Algorithm
produces	O
the	O
solution	O
to	O
the	O
linear	O
independent	O
component	O
analysis	O
(	O
ICA	O
)	O
task	O
.	O
</s>
<s>
This	O
aids	O
in	O
explaining	O
the	O
successful	O
application	O
of	O
k-means	B-Algorithm
to	O
feature	B-General_Concept
learning	I-General_Concept
.	O
</s>
<s>
k-means	B-Algorithm
implicitly	O
assumes	O
that	O
the	O
ordering	O
of	O
the	O
input	O
data	O
set	O
does	O
not	O
matter	O
.	O
</s>
<s>
The	O
bilateral	O
filter	O
is	O
similar	O
to	O
k-means	B-Algorithm
and	O
mean	B-Algorithm
shift	I-Algorithm
in	O
that	O
it	O
maintains	O
a	O
set	O
of	O
data	O
points	O
that	O
are	O
iteratively	O
replaced	O
by	O
means	O
.	O
</s>
<s>
The	O
set	O
of	O
squared	O
error	O
minimizing	O
cluster	O
functions	O
also	O
includes	O
the	O
k-medoids	B-Algorithm
algorithm	O
,	O
an	O
approach	O
which	O
forces	O
the	O
center	O
point	O
of	O
each	O
cluster	O
to	O
be	O
one	O
of	O
the	O
actual	O
points	O
,	O
i.e.	O
,	O
it	O
uses	O
medoids	B-Algorithm
in	O
place	O
of	O
centroids	O
.	O
</s>
<s>
The	O
following	O
implementations	O
are	O
available	O
under	O
Free/Open	B-License
Source	I-License
Software	I-License
licenses	O
,	O
with	O
publicly	O
available	O
source	O
code	O
.	O
</s>
<s>
Accord.NET	B-Application
contains	O
C#	O
implementations	O
for	O
k-means	B-Algorithm
,	O
k-means	B-Algorithm
++	I-Algorithm
and	O
k-modes	O
.	O
</s>
<s>
ALGLIB	B-Library
contains	O
parallelized	O
C++	O
and	O
C#	O
implementations	O
for	O
k-means	B-Algorithm
and	O
k-means	B-Algorithm
++	I-Algorithm
.	O
</s>
<s>
AOSP	O
contains	O
a	O
Java	O
implementation	O
for	O
k-means	B-Algorithm
.	O
</s>
<s>
CrimeStat	O
implements	O
two	O
spatial	O
k-means	B-Algorithm
algorithms	I-Algorithm
,	O
one	O
of	O
which	O
allows	O
the	O
user	O
to	O
define	O
the	O
starting	O
locations	O
.	O
</s>
<s>
ELKI	B-Language
contains	O
k-means	B-Algorithm
(	O
with	O
Lloyd	O
and	O
MacQueen	O
iteration	O
,	O
along	O
with	O
different	O
initializations	O
such	O
as	O
k-means	B-Algorithm
++	I-Algorithm
initialization	O
)	O
and	O
various	O
more	O
advanced	O
clustering	O
algorithms	O
.	O
</s>
<s>
Smile	O
contains	O
k-means	B-Algorithm
and	O
various	O
more	O
other	O
algorithms	O
and	O
results	O
visualization	O
(	O
for	O
java	O
,	O
kotlin	O
and	O
scala	O
)	O
.	O
</s>
<s>
Julia	B-Application
contains	O
a	O
k-means	B-Algorithm
implementation	O
in	O
the	O
JuliaStats	O
Clustering	O
package	O
.	O
</s>
<s>
KNIME	B-Language
contains	O
nodes	O
for	O
k-means	B-Algorithm
and	O
k-medoids	B-Algorithm
.	O
</s>
<s>
Mahout	B-Application
contains	O
a	O
MapReduce	B-Operating_System
based	O
k-means	B-Algorithm
.	O
</s>
<s>
mlpack	B-Language
contains	O
a	O
C++	O
implementation	O
of	O
k-means	B-Algorithm
.	O
</s>
<s>
Octave	B-Language
contains	O
k-means	B-Algorithm
.	O
</s>
<s>
OpenCV	B-Language
contains	O
a	O
k-means	B-Algorithm
implementation	O
.	O
</s>
<s>
Orange	B-Application
includes	O
a	O
component	O
for	O
k-means	B-Algorithm
clustering	I-Algorithm
with	O
automatic	O
selection	O
of	O
k	O
and	O
cluster	O
silhouette	O
scoring	O
.	O
</s>
<s>
PSPP	B-Language
contains	O
k-means	B-Algorithm
,	O
The	O
QUICK	O
CLUSTER	O
command	O
performs	O
k-means	B-Algorithm
clustering	I-Algorithm
on	O
the	O
dataset	O
.	O
</s>
<s>
R	B-Language
contains	O
three	O
k-means	B-Algorithm
variations	O
.	O
</s>
<s>
SciPy	B-Application
and	O
scikit-learn	B-Application
contain	O
multiple	O
k-means	B-Algorithm
implementations	O
.	O
</s>
<s>
Spark	B-Language
MLlib	O
implements	O
a	O
distributed	O
k-means	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
<s>
Torch	B-Algorithm
contains	O
an	O
unsup	O
package	O
that	O
provides	O
k-means	B-Algorithm
clustering	I-Algorithm
.	O
</s>
<s>
Weka	B-Language
contains	O
k-means	B-Algorithm
and	O
x-means	O
.	O
</s>
<s>
The	O
following	O
implementations	O
are	O
available	O
under	O
proprietary	B-Application
license	I-Application
terms	O
,	O
and	O
may	O
not	O
have	O
publicly	O
available	O
source	O
code	O
.	O
</s>
