Hands-On Machine Learning with Scikit-Learn and TensorFlow


Accelerated K-Means and Mini-batch K-Means



Download 26,57 Mb.
Pdf ko'rish
bet196/225
Sana16.03.2022
Hajmi26,57 Mb.
#497859
1   ...   192   193   194   195   196   197   198   199   ...   225
Bog'liq
Hands on Machine Learning with Scikit Learn Keras and TensorFlow

Accelerated K-Means and Mini-batch K-Means
Another important improvement to the K-Means algorithm was proposed in a 
2003
paper
 by Charles Elkan.
3
It considerably accelerates the algorithm by avoiding many
unnecessary distance calculations: this is achieved by exploiting the triangle inequal‐
Clustering | 247


4
The triangle inequality is AC ≤ AB + BC where A, B and C are three points, and AB, AC and BC are the
distances between these points.
5
“Web-Scale K-Means Clustering,” David Sculley (2010).
ity (i.e., the straight line is always the shortest
4
) and by keeping track of lower and
upper bounds for distances between instances and centroids. This is the algorithm
used by default by the 
KMeans
class (but you can force it to use the original algorithm
by setting the 
algorithm
hyperparameter to 
"full"
, although you probably will
never need to).
Yet another important variant of the K-Means algorithm was proposed in a 
2010
paper
 by David Sculley.
5
 Instead of using the full dataset at each iteration, the algo‐
rithm is capable of using mini-batches, moving the centroids just slightly at each iter‐
ation. This speeds up the algorithm typically by a factor of 3 or 4 and makes it
possible to cluster huge datasets that do not fit in memory. Scikit-Learn implements
this algorithm in the 
MiniBatchKMeans
class. You can just use this class like the
KMeans
class:
from
sklearn.cluster
import
MiniBatchKMeans
minibatch_kmeans
=
MiniBatchKMeans
(
n_clusters
=
5
)
minibatch_kmeans
.
fit
(
X
)
If the dataset does not fit in memory, the simplest option is to use the 
memmap
class, as
we did for incremental PCA in 
Chapter 8
. Alternatively, you can pass one mini-batch
at a time to the 
Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   192   193   194   195   196   197   198   199   ...   225




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish