-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathsklearn.cluster.MiniBatchKMeans.html
582 lines (531 loc) · 33.2 KB
/
sklearn.cluster.MiniBatchKMeans.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sklearn.cluster.MiniBatchKMeans — scikit-learn 0.17.1 documentation</title>
<!-- htmltitle is before nature.css - we use this hack to load bootstrap first -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../_static/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" href="../../_static/css/bootstrap-responsive.css"/>
<link rel="stylesheet" href="../../_static/nature.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/gallery.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '0.17.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/js/copybutton.js"></script>
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../../about.html" />
<link rel="top" title="scikit-learn 0.17.1 documentation" href="../../index.html" />
<link rel="up" title="API Reference" href="../classes.html" />
<link rel="next" title="sklearn.cluster.MeanShift" href="sklearn.cluster.MeanShift.html" />
<link rel="prev" title="sklearn.cluster.KMeans" href="sklearn.cluster.KMeans.html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="../../_static/js/bootstrap.min.js" type="text/javascript"></script>
<link rel="canonical" href="https://scikit-learn.org/stable/modules/generated/sklearn.cluster.MiniBatchKMeans.html" />
<script type="text/javascript">
$("div.buttonNext, div.buttonPrevious").hover(
function () {
$(this).css('background-color', '#FF9C34');
},
function () {
$(this).css('background-color', '#A7D6E2');
}
);
</script>
</head>
<body role="document">
<div class="header-wrapper">
<div class="header">
<p class="logo"><a href="../../index.html">
<img src="../../_static/scikit-learn-logo-small.png" alt="Logo"/>
</a>
</p><div class="navbar">
<ul>
<li><a href="../../index.html">Home</a></li>
<li><a href="../../install.html">Installation</a></li>
<li class="btn-li"><div class="btn-group">
<a href="../../documentation.html">Documentation</a>
<a class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="link-title">Scikit-learn 0.17 (stable)</li>
<li><a href="../../tutorial/index.html">Tutorials</a></li>
<li><a href="../../user_guide.html">User guide</a></li>
<li><a href="../classes.html">API</a></li>
<li><a href="../../faq.html">FAQ</a></li>
<li><a href="../../developers/contributing.html">Contributing</a></li>
<li class="divider"></li>
<li><a href="http://scikit-learn.org/dev/documentation.html">Scikit-learn 0.18 (development)</a></li>
<li><a href="http://scikit-learn.org/0.16/documentation.html">Scikit-learn 0.16</a></li>
<li><a href="../../_downloads/scikit-learn-docs.pdf">PDF documentation</a></li>
</ul>
</div>
</li>
<li><a href="../../auto_examples/index.html">Examples</a></li>
</ul>
<div class="search_form">
<div id="cse" style="width: 100%;"></div>
</div>
</div> <!-- end navbar --></div>
</div>
<!-- Github "fork me" ribbon -->
<a href="https://github.com/scikit-learn/scikit-learn">
<img class="fork-me"
style="position: absolute; top: 0; right: 0; border: 0;"
src="../../_static/img/forkme.png"
alt="Fork me on GitHub" />
</a>
<div class="content-wrapper">
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div class="rel">
<!-- rellinks[1:] is an ugly hack to avoid link to module
index -->
<div class="rellink">
<a href="sklearn.cluster.KMeans.html"
accesskey="P">Previous
<br/>
<span class="smallrellink">
sklearn.clust...
</span>
<span class="hiddenrellink">
sklearn.cluster.KMeans
</span>
</a>
</div>
<!-- Ad a link to the 'up' page -->
<div class="spacer">
</div>
<div class="rellink">
<a href="../classes.html">
Up
<br/>
<span class="smallrellink">
API Reference
</span>
<span class="hiddenrellink">
API Reference
</span>
</a>
</div>
</div>
<p class="doc-version">This documentation is for scikit-learn <strong>version 0.17.1</strong> — <a href="http://scikit-learn.org/stable/support.html#documentation-resources">Other versions</a></p>
<p class="citing">If you use the software, please consider <a href="../../about.html#citing-scikit-learn">citing scikit-learn</a>.</p>
<ul>
<li><a class="reference internal" href="#"><code class="docutils literal"><span class="pre">sklearn.cluster</span></code>.MiniBatchKMeans</a><ul>
<li><a class="reference internal" href="#examples-using-sklearn-cluster-minibatchkmeans">Examples using <code class="docutils literal"><span class="pre">sklearn.cluster.MiniBatchKMeans</span></code></a></li>
</ul>
</li>
</ul>
</div>
</div>
<input type="checkbox" id="nav-trigger" class="nav-trigger" checked />
<label for="nav-trigger"></label>
<div class="content">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="sklearn-cluster-minibatchkmeans">
<h1><a class="reference internal" href="../classes.html#module-sklearn.cluster" title="sklearn.cluster"><code class="xref py py-mod docutils literal"><span class="pre">sklearn.cluster</span></code></a>.MiniBatchKMeans<a class="headerlink" href="#sklearn-cluster-minibatchkmeans" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="sklearn.cluster.MiniBatchKMeans">
<em class="property">class </em><code class="descclassname">sklearn.cluster.</code><code class="descname">MiniBatchKMeans</code><span class="sig-paren">(</span><em>n_clusters=8</em>, <em>init='k-means++'</em>, <em>max_iter=100</em>, <em>batch_size=100</em>, <em>verbose=0</em>, <em>compute_labels=True</em>, <em>random_state=None</em>, <em>tol=0.0</em>, <em>max_no_improvement=10</em>, <em>init_size=None</em>, <em>n_init=3</em>, <em>reassignment_ratio=0.01</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L1113"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans" title="Permalink to this definition">¶</a></dt>
<dd><p>Mini-Batch K-Means clustering</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>n_clusters</strong> : int, optional, default: 8</p>
<blockquote>
<div><p>The number of clusters to form as well as the number of
centroids to generate.</p>
</div></blockquote>
<p><strong>max_iter</strong> : int, optional</p>
<blockquote>
<div><p>Maximum number of iterations over the complete dataset before
stopping independently of any early stopping criterion heuristics.</p>
</div></blockquote>
<p><strong>max_no_improvement</strong> : int, default: 10</p>
<blockquote>
<div><p>Control early stopping based on the consecutive number of mini
batches that does not yield an improvement on the smoothed inertia.</p>
<p>To disable convergence detection based on inertia, set
max_no_improvement to None.</p>
</div></blockquote>
<p><strong>tol</strong> : float, default: 0.0</p>
<blockquote>
<div><p>Control early stopping based on the relative center changes as
measured by a smoothed, variance-normalized of the mean center
squared position changes. This early stopping heuristics is
closer to the one used for the batch variant of the algorithms
but induces a slight computational and memory overhead over the
inertia heuristic.</p>
<p>To disable convergence detection based on normalized center
change, set tol to 0.0 (default).</p>
</div></blockquote>
<p><strong>batch_size</strong> : int, optional, default: 100</p>
<blockquote>
<div><p>Size of the mini batches.</p>
</div></blockquote>
<p><strong>init_size</strong> : int, optional, default: 3 * batch_size</p>
<blockquote>
<div><p>Number of samples to randomly sample for speeding up the
initialization (sometimes at the expense of accuracy): the
only algorithm is initialized by running a batch KMeans on a
random subset of the data. This needs to be larger than n_clusters.</p>
</div></blockquote>
<p><strong>init</strong> : {‘k-means++’, ‘random’ or an ndarray}, default: ‘k-means++’</p>
<blockquote>
<div><p>Method for initialization, defaults to ‘k-means++’:</p>
<p>‘k-means++’ : selects initial cluster centers for k-mean
clustering in a smart way to speed up convergence. See section
Notes in k_init for more details.</p>
<p>‘random’: choose k observations (rows) at random from data for
the initial centroids.</p>
<p>If an ndarray is passed, it should be of shape (n_clusters, n_features)
and gives the initial centers.</p>
</div></blockquote>
<p><strong>n_init</strong> : int, default=3</p>
<blockquote>
<div><p>Number of random initializations that are tried.
In contrast to KMeans, the algorithm is only run once, using the
best of the <code class="docutils literal"><span class="pre">n_init</span></code> initializations as measured by inertia.</p>
</div></blockquote>
<p><strong>compute_labels</strong> : boolean, default=True</p>
<blockquote>
<div><p>Compute label assignment and inertia for the complete dataset
once the minibatch optimization has converged in fit.</p>
</div></blockquote>
<p><strong>random_state</strong> : integer or numpy.RandomState, optional</p>
<blockquote>
<div><p>The generator used to initialize the centers. If an integer is
given, it fixes the seed. Defaults to the global numpy random
number generator.</p>
</div></blockquote>
<p><strong>reassignment_ratio</strong> : float, default: 0.01</p>
<blockquote>
<div><p>Control the fraction of the maximum number of counts for a
center to be reassigned. A higher value means that low count
centers are more easily reassigned, which means that the
model will take longer to converge, but should converge in a
better clustering.</p>
</div></blockquote>
<p><strong>verbose</strong> : boolean, optional</p>
<blockquote>
<div><p>Verbosity mode.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Attributes:</th><td class="field-body"><p class="first"><strong>cluster_centers_</strong> : array, [n_clusters, n_features]</p>
<blockquote>
<div><p>Coordinates of cluster centers</p>
</div></blockquote>
<p><strong>labels_ :</strong> :</p>
<blockquote>
<div><p>Labels of each point (if compute_labels is set to True).</p>
</div></blockquote>
<p><strong>inertia_</strong> : float</p>
<blockquote class="last">
<div><p>The value of the inertia criterion associated with the chosen
partition (if compute_labels is set to True). The inertia is
defined as the sum of square distances of samples to their nearest
neighbor.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>See <a class="reference external" href="http://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf">http://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf</a></p>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.fit" title="sklearn.cluster.MiniBatchKMeans.fit"><code class="xref py py-obj docutils literal"><span class="pre">fit</span></code></a>(X[, y])</td>
<td>Compute the centroids on X by chunking it into mini-batches.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.fit_predict" title="sklearn.cluster.MiniBatchKMeans.fit_predict"><code class="xref py py-obj docutils literal"><span class="pre">fit_predict</span></code></a>(X[, y])</td>
<td>Compute cluster centers and predict cluster index for each sample.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.fit_transform" title="sklearn.cluster.MiniBatchKMeans.fit_transform"><code class="xref py py-obj docutils literal"><span class="pre">fit_transform</span></code></a>(X[, y])</td>
<td>Compute clustering and transform X to cluster-distance space.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.get_params" title="sklearn.cluster.MiniBatchKMeans.get_params"><code class="xref py py-obj docutils literal"><span class="pre">get_params</span></code></a>([deep])</td>
<td>Get parameters for this estimator.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.partial_fit" title="sklearn.cluster.MiniBatchKMeans.partial_fit"><code class="xref py py-obj docutils literal"><span class="pre">partial_fit</span></code></a>(X[, y])</td>
<td>Update k means estimate on a single mini-batch X.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.predict" title="sklearn.cluster.MiniBatchKMeans.predict"><code class="xref py py-obj docutils literal"><span class="pre">predict</span></code></a>(X)</td>
<td>Predict the closest cluster each sample in X belongs to.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.score" title="sklearn.cluster.MiniBatchKMeans.score"><code class="xref py py-obj docutils literal"><span class="pre">score</span></code></a>(X[, y])</td>
<td>Opposite of the value of X on the K-means objective.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.set_params" title="sklearn.cluster.MiniBatchKMeans.set_params"><code class="xref py py-obj docutils literal"><span class="pre">set_params</span></code></a>(**params)</td>
<td>Set the parameters of this estimator.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#sklearn.cluster.MiniBatchKMeans.transform" title="sklearn.cluster.MiniBatchKMeans.transform"><code class="xref py py-obj docutils literal"><span class="pre">transform</span></code></a>(X[, y])</td>
<td>Transform X to a cluster-distance space.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em>n_clusters=8</em>, <em>init='k-means++'</em>, <em>max_iter=100</em>, <em>batch_size=100</em>, <em>verbose=0</em>, <em>compute_labels=True</em>, <em>random_state=None</em>, <em>tol=0.0</em>, <em>max_no_improvement=10</em>, <em>init_size=None</em>, <em>n_init=3</em>, <em>reassignment_ratio=0.01</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L1211"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.__init__" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.fit">
<code class="descname">fit</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L1226"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the centroids on X by chunking it into mini-batches.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : array-like, shape = [n_samples, n_features]</p>
<blockquote class="last">
<div><p>Coordinates of the data points to cluster</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.fit_predict">
<code class="descname">fit_predict</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L824"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.fit_predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute cluster centers and predict cluster index for each sample.</p>
<p>Convenience method; equivalent to calling fit(X) followed by
predict(X).</p>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.fit_transform">
<code class="descname">fit_transform</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L832"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.fit_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute clustering and transform X to cluster-distance space.</p>
<p>Equivalent to fit(X).transform(X), but more efficiently implemented.</p>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.get_params">
<code class="descname">get_params</code><span class="sig-paren">(</span><em>deep=True</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/base.py#L199"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.get_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Get parameters for this estimator.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>deep: boolean, optional</strong> :</p>
<blockquote>
<div><p>If True, will return the parameters for this estimator and
contained subobjects that are estimators.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>params</strong> : mapping of string to any</p>
<blockquote class="last">
<div><p>Parameter names mapped to their values.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.partial_fit">
<code class="descname">partial_fit</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L1388"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.partial_fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Update k means estimate on a single mini-batch X.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : array-like, shape = [n_samples, n_features]</p>
<blockquote class="last">
<div><p>Coordinates of the data points to cluster.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.predict">
<code class="descname">predict</code><span class="sig-paren">(</span><em>X</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L1441"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Predict the closest cluster each sample in X belongs to.</p>
<p>In the vector quantization literature, <cite>cluster_centers_</cite> is called
the code book and each value returned by <cite>predict</cite> is the index of
the closest code in the code book.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : {array-like, sparse matrix}, shape = [n_samples, n_features]</p>
<blockquote>
<div><p>New data to predict.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>labels</strong> : array, shape [n_samples,]</p>
<blockquote class="last">
<div><p>Index of the cluster each sample belongs to.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.score">
<code class="descname">score</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L893"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.score" title="Permalink to this definition">¶</a></dt>
<dd><p>Opposite of the value of X on the K-means objective.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : {array-like, sparse matrix}, shape = [n_samples, n_features]</p>
<blockquote>
<div><p>New data.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>score</strong> : float</p>
<blockquote class="last">
<div><p>Opposite of the value of X on the K-means objective.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.set_params">
<code class="descname">set_params</code><span class="sig-paren">(</span><em>**params</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/base.py#L236"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.set_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the parameters of this estimator.</p>
<p>The method works on simple estimators as well as on nested objects
(such as pipelines). The former have parameters of the form
<code class="docutils literal"><span class="pre"><component>__<parameter></span></code> so that it’s possible to update each
component of a nested object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>self</strong> :</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="sklearn.cluster.MiniBatchKMeans.transform">
<code class="descname">transform</code><span class="sig-paren">(</span><em>X</em>, <em>y=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/cluster/k_means_.py#L844"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.cluster.MiniBatchKMeans.transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform X to a cluster-distance space.</p>
<p>In the new space, each dimension is the distance to the cluster
centers. Note that even if X is sparse, the array returned by
<cite>transform</cite> will typically be dense.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : {array-like, sparse matrix}, shape = [n_samples, n_features]</p>
<blockquote>
<div><p>New data to transform.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>X_new</strong> : array, shape [n_samples, k]</p>
<blockquote class="last">
<div><p>X transformed in the new space.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<div class="section" id="examples-using-sklearn-cluster-minibatchkmeans">
<h2>Examples using <code class="docutils literal"><span class="pre">sklearn.cluster.MiniBatchKMeans</span></code><a class="headerlink" href="#examples-using-sklearn-cluster-minibatchkmeans" title="Permalink to this headline">¶</a></h2>
<div class="thumbnailContainer" tooltip="This example demonstrates the Spectral Co-clustering algorithm on the twenty newsgroups dataset..."><div class="figure" id="id1">
<a class="reference external image-reference" href="./../../auto_examples/bicluster/bicluster_newsgroups.html"><img alt="../../_images/bicluster_newsgroups1.png" src="../../_images/bicluster_newsgroups1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/bicluster/bicluster_newsgroups.html#example-bicluster-bicluster-newsgroups-py"><span>Biclustering documents with the Spectral Co-clustering algorithm</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="This example uses a large dataset of faces to learn a set of 20 x 20 images patches that consti..."><div class="figure" id="id2">
<a class="reference external image-reference" href="./../../auto_examples/cluster/plot_dict_face_patches.html"><img alt="../../_images/plot_dict_face_patches1.png" src="../../_images/plot_dict_face_patches1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/cluster/plot_dict_face_patches.html#example-cluster-plot-dict-face-patches-py"><span>Online learning of a dictionary of parts of faces</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="This example compares the timing of Birch (with and without the global clustering step) and Min..."><div class="figure" id="id3">
<a class="reference external image-reference" href="./../../auto_examples/cluster/plot_birch_vs_minibatchkmeans.html"><img alt="../../_images/plot_birch_vs_minibatchkmeans1.png" src="../../_images/plot_birch_vs_minibatchkmeans1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/cluster/plot_birch_vs_minibatchkmeans.html#example-cluster-plot-birch-vs-minibatchkmeans-py"><span>Compare BIRCH and MiniBatchKMeans</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="Evaluate the ability of k-means initializations strategies to make the algorithm convergence ro..."><div class="figure" id="id4">
<a class="reference external image-reference" href="./../../auto_examples/cluster/plot_kmeans_stability_low_dim_dense.html"><img alt="../../_images/plot_kmeans_stability_low_dim_dense1.png" src="../../_images/plot_kmeans_stability_low_dim_dense1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/cluster/plot_kmeans_stability_low_dim_dense.html#example-cluster-plot-kmeans-stability-low-dim-dense-py"><span>Empirical evaluation of the impact of k-means initialization</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="This example aims at showing characteristics of different clustering algorithms on datasets tha..."><div class="figure" id="id5">
<a class="reference external image-reference" href="./../../auto_examples/cluster/plot_cluster_comparison.html"><img alt="../../_images/plot_cluster_comparison1.png" src="../../_images/plot_cluster_comparison1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/cluster/plot_cluster_comparison.html#example-cluster-plot-cluster-comparison-py"><span>Comparing different clustering algorithms on toy datasets</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="We want to compare the performance of the MiniBatchKMeans and KMeans: the MiniBatchKMeans is fa..."><div class="figure" id="id6">
<a class="reference external image-reference" href="./../../auto_examples/cluster/plot_mini_batch_kmeans.html"><img alt="../../_images/plot_mini_batch_kmeans1.png" src="../../_images/plot_mini_batch_kmeans1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/cluster/plot_mini_batch_kmeans.html#example-cluster-plot-mini-batch-kmeans-py"><span>Comparison of the K-Means and MiniBatchKMeans clustering algorithms</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="This example applies to :ref:`olivetti_faces` different unsupervised matrix decomposition (dime..."><div class="figure" id="id7">
<a class="reference external image-reference" href="./../../auto_examples/decomposition/plot_faces_decomposition.html"><img alt="../../_images/plot_faces_decomposition1.png" src="../../_images/plot_faces_decomposition1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/decomposition/plot_faces_decomposition.html#example-decomposition-plot-faces-decomposition-py"><span>Faces dataset decompositions</span></a></span></p>
</div>
</div><div class="thumbnailContainer" tooltip="This is an example showing how the scikit-learn can be used to cluster documents by topics usin..."><div class="figure" id="id8">
<a class="reference external image-reference" href="./../../auto_examples/text/document_clustering.html"><img alt="../../_images/document_clustering1.png" src="../../_images/document_clustering1.png" /></a>
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/text/document_clustering.html#example-text-document-clustering-py"><span>Clustering text documents using k-means</span></a></span></p>
</div>
</div><div class="clearer"></div></div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div class="footer">
© 2010 - 2014, scikit-learn developers (BSD License).
<a href="../../_sources/modules/generated/sklearn.cluster.MiniBatchKMeans.txt" rel="nofollow">Show this page source</a>
</div>
<div class="rel">
<div class="buttonPrevious">
<a href="sklearn.cluster.KMeans.html">Previous
</a>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22606712-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript"> google.load('search', '1',
{language : 'en'}); google.setOnLoadCallback(function() {
var customSearchControl = new
google.search.CustomSearchControl('016639176250731907682:tjtqbvtvij0');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setAutoComplete(true);
customSearchControl.draw('cse', options); }, true);
</script>
<script src="https://scikit-learn.org/versionwarning.js"></script>
</body>
</html>