8.4.12. Clustering methods to learn a brain parcellation from rest fMRI

We use spatially-constrained Ward-clustering and KMeans to create a set of parcels.

In a high dimensional regime, these methods can be interesting to create a ‘compressed’ representation of the data, replacing the data in the fMRI images by mean signals on the parcellation, which can subsequently be used for statistical analysis or machine learning.

Also, these methods can be used to learn functional connectomes and subsequently for classification tasks.

8.4.12.1. References

Which clustering method to use, an empirical comparison can be found in this paper

This parcellation may be useful in a supervised learning, see for instance

The big picture discussion corresponding to this example can be found in the documentation section Clustering to parcellate the brain in regions.

8.4.12.2. Download a rest dataset and turn it to a data matrix

We download one subject of the ADHD dataset from Internet

from nilearn import datasets
dataset = datasets.fetch_adhd(n_subjects=1)

# print basic information on the dataset
print('First subject functional nifti image (4D) is at: %s' %
      dataset.func[0])  # 4D data

Out:

First subject functional nifti image (4D) is at: /home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz

8.4.12.3. Brain parcellations with Ward Clustering

Transforming list of images to data matrix and build brain parcellations, all can be done at once using Parcellations object.

from nilearn.regions import Parcellations

# Computing ward for the first time, will be long... This can be seen by
# measuring using time
import time
start = time.time()

# Agglomerative Clustering: ward

# We build parameters of our own for this object. Parameters related to
# masking, caching and defining number of clusters and specific parcellations
# method.
ward = Parcellations(method='ward', n_parcels=1000,
                     standardize=False, smoothing_fwhm=2.,
                     memory='nilearn_cache', memory_level=1,
                     verbose=1)
# Call fit on functional dataset: single subject (less samples).
ward.fit(dataset.func)
print("Ward agglomeration 1000 clusters: %.2fs" % (time.time() - start))

# We compute now ward clustering with 2000 clusters and compare
# time with 1000 clusters. To see the benefits of caching for second time.

# We initialize class again with n_parcels=2000 this time.
start = time.time()
ward = Parcellations(method='ward', n_parcels=2000,
                     standardize=False, smoothing_fwhm=2.,
                     memory='nilearn_cache', memory_level=1,
                     verbose=1)
ward.fit(dataset.func)
print("Ward agglomeration 2000 clusters: %.2fs" % (time.time() - start))

Out:

[MultiNiftiMasker.fit] Loading data from [/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz]
[MultiNiftiMasker.fit] Computing mask
[MultiNiftiMasker.transform] Resampling mask
[Parcellations] Loading data
[MultiNiftiMasker.transform_single_imgs] Loading data from Nifti1Image('/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz')
[MultiNiftiMasker.transform_single_imgs] Smoothing images
[MultiNiftiMasker.transform_single_imgs] Extracting region signals
[MultiNiftiMasker.transform_single_imgs] Cleaning extracted signals
[Parcellations] computing ward
________________________________________________________________________________
[Memory] Calling nilearn.regions.parcellations._estimator_fit...
_estimator_fit(array([[-0.007822, ...,  0.000102],
       ...,
       [ 0.00173 , ...,  0.002701]], dtype=float32),
AgglomerativeClustering(affinity='euclidean', compute_full_tree='auto',
            connectivity=<62546x62546 sparse matrix of type '<class 'numpy.int64'>'
        with 423954 stored elements in COOrdinate format>,
            linkage='ward', memory=Memory(cachedir='nilearn_cache/joblib'),
            n_clusters=1000, pooling_func='deprecated'))
________________________________________________________________________________
[Memory] Calling sklearn.cluster.hierarchical.ward_tree...
ward_tree(array([[-0.007822, ...,  0.00173 ],
       ...,
       [ 0.000102, ...,  0.002701]], dtype=float32),
<62546x62546 sparse matrix of type '<class 'numpy.int64'>'
        with 423954 stored elements in COOrdinate format>, n_clusters=None)
________________________________________________________ward_tree - 6.6s, 0.1min
____________________________________________________estimator_fit - 6.9s, 0.1min
Ward agglomeration 1000 clusters: 24.75s
[MultiNiftiMasker.fit] Loading data from [/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz]
[MultiNiftiMasker.fit] Computing mask
[MultiNiftiMasker.transform] Resampling mask
[Parcellations] Loading data
[Parcellations] computing ward
________________________________________________________________________________
[Memory] Calling nilearn.regions.parcellations._estimator_fit...
_estimator_fit(array([[-0.007822, ...,  0.000102],
       ...,
       [ 0.00173 , ...,  0.002701]], dtype=float32),
AgglomerativeClustering(affinity='euclidean', compute_full_tree='auto',
            connectivity=<62546x62546 sparse matrix of type '<class 'numpy.int64'>'
        with 423954 stored elements in COOrdinate format>,
            linkage='ward', memory=Memory(cachedir='nilearn_cache/joblib'),
            n_clusters=2000, pooling_func='deprecated'))
________________________________________________________________________________
[Memory] Calling sklearn.cluster.hierarchical.ward_tree...
ward_tree(array([[-0.007822, ...,  0.00173 ],
       ...,
       [ 0.000102, ...,  0.002701]], dtype=float32),
<62546x62546 sparse matrix of type '<class 'numpy.int64'>'
        with 423954 stored elements in COOrdinate format>, n_clusters=2000)
________________________________________________________ward_tree - 6.2s, 0.1min
____________________________________________________estimator_fit - 6.4s, 0.1min
Ward agglomeration 2000 clusters: 20.80s

8.4.12.4. Visualize: Brain parcellations (Ward)

First, we display the parcellations of the brain image stored in attribute labels_img_

ward_labels_img = ward.labels_img_

# Now, ward_labels_img are Nifti1Image object, it can be saved to file
# with the following code:
ward_labels_img.to_filename('ward_parcellation.nii.gz')

from nilearn import plotting
from nilearn.image import mean_img, index_img

first_plot = plotting.plot_roi(ward_labels_img, title="Ward parcellation",
                               display_mode='xz')

# Grab cut coordinates from this plot to use as a common for all plots
cut_coords = first_plot.cut_coords
../../_images/sphx_glr_plot_rest_parcellations_001.png

8.4.12.5. Compressed representation of Ward clustering

Second, we illustrate the effect that the clustering has on the signal. We show the original data, and the approximation provided by the clustering by averaging the signal on each parcel.

# Grab number of voxels from attribute mask image (mask_img_).
import numpy as np
original_voxels = np.sum(ward.mask_img_.get_data())

# Compute mean over time on the functional image to use the mean
# image for compressed representation comparisons
mean_func_img = mean_img(dataset.func[0])

# Compute common vmin and vmax
vmin = np.min(mean_func_img.get_data())
vmax = np.max(mean_func_img.get_data())

plotting.plot_epi(mean_func_img, cut_coords=cut_coords,
                  title='Original (%i voxels)' % original_voxels,
                  vmax=vmax, vmin=vmin, display_mode='xz')

# A reduced dataset can be created by taking the parcel-level average:
# Note that Parcellation objects with any method have the opportunity to
# use a `transform` call that modifies input features. Here it reduces their
# dimension. Note that we `fit` before calling a `transform` so that average
# signals can be created on the brain parcellations with fit call.
fmri_reduced = ward.transform(dataset.func)

# Display the corresponding data compressed using the parcellation using
# parcels=2000.
fmri_compressed = ward.inverse_transform(fmri_reduced)

plotting.plot_epi(index_img(fmri_compressed, 0),
                  cut_coords=cut_coords,
                  title='Ward compressed representation (2000 parcels)',
                  vmin=vmin, vmax=vmax, display_mode='xz')
# As you can see below, this approximation is almost good, although there
# are only 2000 parcels, instead of the original 60000 voxels
  • ../../_images/sphx_glr_plot_rest_parcellations_002.png
  • ../../_images/sphx_glr_plot_rest_parcellations_003.png

Out:

[Parcellations.transform] loading data from Nifti1Image('ward_parcellation.nii.gz')
[Parcellations.transform] loading data from Nifti1Image(
shape=(61, 73, 61),
affine=array([[  -3.,   -0.,   -0.,   90.],
       [  -0.,    3.,   -0., -126.],
       [   0.,    0.,    3.,  -72.],
       [   0.,    0.,    0.,    1.]])
)
________________________________________________________________________________
[Memory] Calling nilearn.input_data.base_masker.filter_and_extract...
filter_and_extract(<nibabel.nifti1.Nifti1Image object at 0x7f2043070f98>, <nilearn.input_data.nifti_labels_masker._ExtractionFunctor object at 0x7f204307a3c8>,
{ 'background_label': 0,
  'detrend': False,
  'high_pass': None,
  'labels_img': <nibabel.nifti1.Nifti1Image object at 0x7f204307a208>,
  'low_pass': None,
  'mask_img': <nibabel.nifti1.Nifti1Image object at 0x7f204307a198>,
  'smoothing_fwhm': 2.0,
  'standardize': False,
  't_r': None,
  'target_affine': None,
  'target_shape': None}, confounds=None, memory=Memory(cachedir='nilearn_cache/joblib'), memory_level=1, verbose=1)
[NiftiLabelsMasker.transform_single_imgs] Loading data from Nifti1Image('/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz')
[NiftiLabelsMasker.transform_single_imgs] Smoothing images
[NiftiLabelsMasker.transform_single_imgs] Extracting region signals
[NiftiLabelsMasker.transform_single_imgs] Cleaning extracted signals
_______________________________________________filter_and_extract - 4.2s, 0.1min

8.4.12.6. Brain parcellations with KMeans Clustering

We use the same approach as with building parcellations using Ward clustering. But, in the range of a small number of clusters, it is most likely that we want to use standardization. Indeed with standardization and smoothing, the clusters will form as regions.

# class/functions can be used here as they are already imported above.

# This object uses method='kmeans' for KMeans clustering with 10mm smoothing
# and standardization ON
kmeans = Parcellations(method='kmeans', n_parcels=50,
                       standardize=True, smoothing_fwhm=10.,
                       memory='nilearn_cache', memory_level=1,
                       verbose=1)
# Call fit on functional dataset: single subject (less samples)
kmeans.fit(dataset.func)
print("KMeans 50 clusters: %.2fs" % (time.time() - start))

Out:

[MultiNiftiMasker.fit] Loading data from [/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz]
[MultiNiftiMasker.fit] Computing mask
[MultiNiftiMasker.transform] Resampling mask
[Parcellations] Loading data
[MultiNiftiMasker.transform_single_imgs] Loading data from Nifti1Image('/home/varoquau/nilearn_data/adhd/data/0010042/0010042_rest_tshift_RPI_voreg_mni.nii.gz')
[MultiNiftiMasker.transform_single_imgs] Smoothing images
[MultiNiftiMasker.transform_single_imgs] Extracting region signals
[MultiNiftiMasker.transform_single_imgs] Cleaning extracted signals
[Parcellations] computing kmeans
________________________________________________________________________________
[Memory] Calling nilearn.regions.parcellations._estimator_fit...
_estimator_fit(array([[ 0.009257, ...,  0.005533],
       ...,
       [-0.001246, ..., -0.007178]], dtype=float32),
MiniBatchKMeans(batch_size=100, compute_labels=True, init='k-means++',
        init_size=None, max_iter=100, max_no_improvement=10, n_clusters=50,
        n_init=3, random_state=0, reassignment_ratio=0.01, tol=0.0,
        verbose=1))
Init 1/3 with method: k-means++
Inertia for init 1/3: 0.740556
Init 2/3 with method: k-means++
Inertia for init 2/3: 0.745638
Init 3/3 with method: k-means++
Inertia for init 3/3: 0.746695
Minibatch iteration 1/62600: mean batch inertia: 0.003009, ewa inertia: 0.003009
Minibatch iteration 2/62600: mean batch inertia: 0.002808, ewa inertia: 0.003009
Minibatch iteration 3/62600: mean batch inertia: 0.002809, ewa inertia: 0.003008
Minibatch iteration 4/62600: mean batch inertia: 0.002861, ewa inertia: 0.003008
Minibatch iteration 5/62600: mean batch inertia: 0.002540, ewa inertia: 0.003006
Minibatch iteration 6/62600: mean batch inertia: 0.002822, ewa inertia: 0.003005
Minibatch iteration 7/62600: mean batch inertia: 0.002531, ewa inertia: 0.003004
Minibatch iteration 8/62600: mean batch inertia: 0.002908, ewa inertia: 0.003004
Minibatch iteration 9/62600: mean batch inertia: 0.002658, ewa inertia: 0.003002
[MiniBatchKMeans] Reassigning 44 cluster centers.
Minibatch iteration 10/62600: mean batch inertia: 0.002707, ewa inertia: 0.003002
Minibatch iteration 11/62600: mean batch inertia: 0.002828, ewa inertia: 0.003001
Minibatch iteration 12/62600: mean batch inertia: 0.002540, ewa inertia: 0.003000
Minibatch iteration 13/62600: mean batch inertia: 0.002655, ewa inertia: 0.002998
Minibatch iteration 14/62600: mean batch inertia: 0.002841, ewa inertia: 0.002998
Minibatch iteration 15/62600: mean batch inertia: 0.002707, ewa inertia: 0.002997
Minibatch iteration 16/62600: mean batch inertia: 0.002760, ewa inertia: 0.002996
Minibatch iteration 17/62600: mean batch inertia: 0.002795, ewa inertia: 0.002996
Minibatch iteration 18/62600: mean batch inertia: 0.002485, ewa inertia: 0.002994
[MiniBatchKMeans] Reassigning 19 cluster centers.
Minibatch iteration 19/62600: mean batch inertia: 0.002469, ewa inertia: 0.002992
[MiniBatchKMeans] Reassigning 28 cluster centers.
Minibatch iteration 20/62600: mean batch inertia: 0.002648, ewa inertia: 0.002991
Minibatch iteration 21/62600: mean batch inertia: 0.002662, ewa inertia: 0.002990
Minibatch iteration 22/62600: mean batch inertia: 0.002700, ewa inertia: 0.002989
Minibatch iteration 23/62600: mean batch inertia: 0.002814, ewa inertia: 0.002989
Minibatch iteration 24/62600: mean batch inertia: 0.002582, ewa inertia: 0.002987
Minibatch iteration 25/62600: mean batch inertia: 0.002514, ewa inertia: 0.002986
Minibatch iteration 26/62600: mean batch inertia: 0.002583, ewa inertia: 0.002985
Minibatch iteration 27/62600: mean batch inertia: 0.002763, ewa inertia: 0.002984
Minibatch iteration 28/62600: mean batch inertia: 0.002718, ewa inertia: 0.002983
Minibatch iteration 29/62600: mean batch inertia: 0.002691, ewa inertia: 0.002982
Minibatch iteration 30/62600: mean batch inertia: 0.002492, ewa inertia: 0.002980
Minibatch iteration 31/62600: mean batch inertia: 0.002907, ewa inertia: 0.002980
Minibatch iteration 32/62600: mean batch inertia: 0.002728, ewa inertia: 0.002979
Minibatch iteration 33/62600: mean batch inertia: 0.002794, ewa inertia: 0.002979
Minibatch iteration 34/62600: mean batch inertia: 0.002781, ewa inertia: 0.002978
Minibatch iteration 35/62600: mean batch inertia: 0.002704, ewa inertia: 0.002977
Minibatch iteration 36/62600: mean batch inertia: 0.002552, ewa inertia: 0.002976
Minibatch iteration 37/62600: mean batch inertia: 0.002635, ewa inertia: 0.002975
Minibatch iteration 38/62600: mean batch inertia: 0.002762, ewa inertia: 0.002974
Minibatch iteration 39/62600: mean batch inertia: 0.002874, ewa inertia: 0.002974
Minibatch iteration 40/62600: mean batch inertia: 0.002744, ewa inertia: 0.002973
Minibatch iteration 41/62600: mean batch inertia: 0.002619, ewa inertia: 0.002972
[MiniBatchKMeans] Reassigning 40 cluster centers.
Minibatch iteration 42/62600: mean batch inertia: 0.002647, ewa inertia: 0.002971
Minibatch iteration 43/62600: mean batch inertia: 0.002800, ewa inertia: 0.002970
Minibatch iteration 44/62600: mean batch inertia: 0.002660, ewa inertia: 0.002969
Minibatch iteration 45/62600: mean batch inertia: 0.002688, ewa inertia: 0.002969
Minibatch iteration 46/62600: mean batch inertia: 0.002681, ewa inertia: 0.002968
Minibatch iteration 47/62600: mean batch inertia: 0.002934, ewa inertia: 0.002968
Minibatch iteration 48/62600: mean batch inertia: 0.002739, ewa inertia: 0.002967
Minibatch iteration 49/62600: mean batch inertia: 0.002705, ewa inertia: 0.002966
Minibatch iteration 50/62600: mean batch inertia: 0.002779, ewa inertia: 0.002965
Minibatch iteration 51/62600: mean batch inertia: 0.002722, ewa inertia: 0.002965
Minibatch iteration 52/62600: mean batch inertia: 0.002563, ewa inertia: 0.002963
Minibatch iteration 53/62600: mean batch inertia: 0.002939, ewa inertia: 0.002963
Minibatch iteration 54/62600: mean batch inertia: 0.002661, ewa inertia: 0.002962
Minibatch iteration 55/62600: mean batch inertia: 0.002589, ewa inertia: 0.002961
Minibatch iteration 56/62600: mean batch inertia: 0.002636, ewa inertia: 0.002960
Minibatch iteration 57/62600: mean batch inertia: 0.002628, ewa inertia: 0.002959
Minibatch iteration 58/62600: mean batch inertia: 0.002685, ewa inertia: 0.002958
Minibatch iteration 59/62600: mean batch inertia: 0.002545, ewa inertia: 0.002957
Minibatch iteration 60/62600: mean batch inertia: 0.002677, ewa inertia: 0.002956
Minibatch iteration 61/62600: mean batch inertia: 0.002800, ewa inertia: 0.002955
[MiniBatchKMeans] Reassigning 37 cluster centers.
Minibatch iteration 62/62600: mean batch inertia: 0.002617, ewa inertia: 0.002954
Minibatch iteration 63/62600: mean batch inertia: 0.002915, ewa inertia: 0.002954
Minibatch iteration 64/62600: mean batch inertia: 0.002613, ewa inertia: 0.002953
Minibatch iteration 65/62600: mean batch inertia: 0.002727, ewa inertia: 0.002952
Minibatch iteration 66/62600: mean batch inertia: 0.002682, ewa inertia: 0.002951
Minibatch iteration 67/62600: mean batch inertia: 0.003002, ewa inertia: 0.002952
Minibatch iteration 68/62600: mean batch inertia: 0.002785, ewa inertia: 0.002951
Minibatch iteration 69/62600: mean batch inertia: 0.002798, ewa inertia: 0.002951
Minibatch iteration 70/62600: mean batch inertia: 0.002863, ewa inertia: 0.002950
Minibatch iteration 71/62600: mean batch inertia: 0.002774, ewa inertia: 0.002950
Minibatch iteration 72/62600: mean batch inertia: 0.002616, ewa inertia: 0.002949
Minibatch iteration 73/62600: mean batch inertia: 0.002450, ewa inertia: 0.002947
Minibatch iteration 74/62600: mean batch inertia: 0.002944, ewa inertia: 0.002947
Minibatch iteration 75/62600: mean batch inertia: 0.002686, ewa inertia: 0.002946
Minibatch iteration 76/62600: mean batch inertia: 0.002782, ewa inertia: 0.002946
Minibatch iteration 77/62600: mean batch inertia: 0.002718, ewa inertia: 0.002945
[MiniBatchKMeans] Reassigning 36 cluster centers.
Minibatch iteration 78/62600: mean batch inertia: 0.002687, ewa inertia: 0.002944
Minibatch iteration 79/62600: mean batch inertia: 0.002502, ewa inertia: 0.002943
Minibatch iteration 80/62600: mean batch inertia: 0.002752, ewa inertia: 0.002942
Minibatch iteration 81/62600: mean batch inertia: 0.002854, ewa inertia: 0.002942
Minibatch iteration 82/62600: mean batch inertia: 0.002424, ewa inertia: 0.002940
Minibatch iteration 83/62600: mean batch inertia: 0.003008, ewa inertia: 0.002940
Minibatch iteration 84/62600: mean batch inertia: 0.002643, ewa inertia: 0.002939
Minibatch iteration 85/62600: mean batch inertia: 0.002546, ewa inertia: 0.002938
Minibatch iteration 86/62600: mean batch inertia: 0.002487, ewa inertia: 0.002937
Minibatch iteration 87/62600: mean batch inertia: 0.002519, ewa inertia: 0.002935
Minibatch iteration 88/62600: mean batch inertia: 0.002764, ewa inertia: 0.002935
Minibatch iteration 89/62600: mean batch inertia: 0.002575, ewa inertia: 0.002934
[MiniBatchKMeans] Reassigning 38 cluster centers.
Minibatch iteration 90/62600: mean batch inertia: 0.002610, ewa inertia: 0.002933
Minibatch iteration 91/62600: mean batch inertia: 0.002555, ewa inertia: 0.002931
Minibatch iteration 92/62600: mean batch inertia: 0.002723, ewa inertia: 0.002931
Minibatch iteration 93/62600: mean batch inertia: 0.002888, ewa inertia: 0.002931
Minibatch iteration 94/62600: mean batch inertia: 0.002780, ewa inertia: 0.002930
Minibatch iteration 95/62600: mean batch inertia: 0.002722, ewa inertia: 0.002930
Minibatch iteration 96/62600: mean batch inertia: 0.002756, ewa inertia: 0.002929
Minibatch iteration 97/62600: mean batch inertia: 0.002811, ewa inertia: 0.002929
Minibatch iteration 98/62600: mean batch inertia: 0.002678, ewa inertia: 0.002928
Minibatch iteration 99/62600: mean batch inertia: 0.002630, ewa inertia: 0.002927
[MiniBatchKMeans] Reassigning 36 cluster centers.
Minibatch iteration 100/62600: mean batch inertia: 0.002662, ewa inertia: 0.002926
Minibatch iteration 101/62600: mean batch inertia: 0.002965, ewa inertia: 0.002926
Minibatch iteration 102/62600: mean batch inertia: 0.002543, ewa inertia: 0.002925
Minibatch iteration 103/62600: mean batch inertia: 0.002621, ewa inertia: 0.002924
Minibatch iteration 104/62600: mean batch inertia: 0.002696, ewa inertia: 0.002923
Minibatch iteration 105/62600: mean batch inertia: 0.002610, ewa inertia: 0.002922
Minibatch iteration 106/62600: mean batch inertia: 0.002613, ewa inertia: 0.002921
Minibatch iteration 107/62600: mean batch inertia: 0.002777, ewa inertia: 0.002921
[MiniBatchKMeans] Reassigning 35 cluster centers.
Minibatch iteration 108/62600: mean batch inertia: 0.002695, ewa inertia: 0.002920
Minibatch iteration 109/62600: mean batch inertia: 0.002834, ewa inertia: 0.002920
Minibatch iteration 110/62600: mean batch inertia: 0.002820, ewa inertia: 0.002919
Minibatch iteration 111/62600: mean batch inertia: 0.002669, ewa inertia: 0.002919
Minibatch iteration 112/62600: mean batch inertia: 0.002632, ewa inertia: 0.002918
Minibatch iteration 113/62600: mean batch inertia: 0.002664, ewa inertia: 0.002917
[MiniBatchKMeans] Reassigning 36 cluster centers.
Minibatch iteration 114/62600: mean batch inertia: 0.002788, ewa inertia: 0.002917
Minibatch iteration 115/62600: mean batch inertia: 0.002726, ewa inertia: 0.002916
Minibatch iteration 116/62600: mean batch inertia: 0.002630, ewa inertia: 0.002915
Minibatch iteration 117/62600: mean batch inertia: 0.002724, ewa inertia: 0.002914
Minibatch iteration 118/62600: mean batch inertia: 0.002683, ewa inertia: 0.002914
Minibatch iteration 119/62600: mean batch inertia: 0.002791, ewa inertia: 0.002913
[MiniBatchKMeans] Reassigning 37 cluster centers.
Minibatch iteration 120/62600: mean batch inertia: 0.002553, ewa inertia: 0.002912
Minibatch iteration 121/62600: mean batch inertia: 0.002733, ewa inertia: 0.002912
Minibatch iteration 122/62600: mean batch inertia: 0.002628, ewa inertia: 0.002911
Minibatch iteration 123/62600: mean batch inertia: 0.002718, ewa inertia: 0.002910
Minibatch iteration 124/62600: mean batch inertia: 0.002768, ewa inertia: 0.002910
Minibatch iteration 125/62600: mean batch inertia: 0.002852, ewa inertia: 0.002909
[MiniBatchKMeans] Reassigning 31 cluster centers.
Minibatch iteration 126/62600: mean batch inertia: 0.002771, ewa inertia: 0.002909
Minibatch iteration 127/62600: mean batch inertia: 0.002583, ewa inertia: 0.002908
Minibatch iteration 128/62600: mean batch inertia: 0.002838, ewa inertia: 0.002908
Minibatch iteration 129/62600: mean batch inertia: 0.002671, ewa inertia: 0.002907
[MiniBatchKMeans] Reassigning 25 cluster centers.
Minibatch iteration 130/62600: mean batch inertia: 0.002787, ewa inertia: 0.002906
Minibatch iteration 131/62600: mean batch inertia: 0.002975, ewa inertia: 0.002907
[MiniBatchKMeans] Reassigning 27 cluster centers.
Minibatch iteration 132/62600: mean batch inertia: 0.002730, ewa inertia: 0.002906
Minibatch iteration 133/62600: mean batch inertia: 0.002664, ewa inertia: 0.002905
[MiniBatchKMeans] Reassigning 27 cluster centers.
Minibatch iteration 134/62600: mean batch inertia: 0.002733, ewa inertia: 0.002905
Minibatch iteration 135/62600: mean batch inertia: 0.002470, ewa inertia: 0.002903
[MiniBatchKMeans] Reassigning 27 cluster centers.
Minibatch iteration 136/62600: mean batch inertia: 0.002675, ewa inertia: 0.002903
Minibatch iteration 137/62600: mean batch inertia: 0.002921, ewa inertia: 0.002903
[MiniBatchKMeans] Reassigning 33 cluster centers.
Minibatch iteration 138/62600: mean batch inertia: 0.002809, ewa inertia: 0.002902
Minibatch iteration 139/62600: mean batch inertia: 0.002737, ewa inertia: 0.002902
Minibatch iteration 140/62600: mean batch inertia: 0.002479, ewa inertia: 0.002901
Minibatch iteration 141/62600: mean batch inertia: 0.002639, ewa inertia: 0.002900
Minibatch iteration 142/62600: mean batch inertia: 0.002765, ewa inertia: 0.002899
Minibatch iteration 143/62600: mean batch inertia: 0.002818, ewa inertia: 0.002899
Minibatch iteration 144/62600: mean batch inertia: 0.002639, ewa inertia: 0.002898
Minibatch iteration 145/62600: mean batch inertia: 0.002705, ewa inertia: 0.002898
Minibatch iteration 146/62600: mean batch inertia: 0.002461, ewa inertia: 0.002896
Minibatch iteration 147/62600: mean batch inertia: 0.002648, ewa inertia: 0.002895
Minibatch iteration 148/62600: mean batch inertia: 0.002537, ewa inertia: 0.002894
Minibatch iteration 149/62600: mean batch inertia: 0.002826, ewa inertia: 0.002894
Minibatch iteration 150/62600: mean batch inertia: 0.002634, ewa inertia: 0.002893
Minibatch iteration 151/62600: mean batch inertia: 0.002805, ewa inertia: 0.002893
Minibatch iteration 152/62600: mean batch inertia: 0.002794, ewa inertia: 0.002893
Minibatch iteration 153/62600: mean batch inertia: 0.002466, ewa inertia: 0.002891
Minibatch iteration 154/62600: mean batch inertia: 0.002846, ewa inertia: 0.002891
Minibatch iteration 155/62600: mean batch inertia: 0.002564, ewa inertia: 0.002890
Minibatch iteration 156/62600: mean batch inertia: 0.002583, ewa inertia: 0.002889
Minibatch iteration 157/62600: mean batch inertia: 0.002530, ewa inertia: 0.002888
Minibatch iteration 158/62600: mean batch inertia: 0.002778, ewa inertia: 0.002888
Minibatch iteration 159/62600: mean batch inertia: 0.002783, ewa inertia: 0.002887
Minibatch iteration 160/62600: mean batch inertia: 0.002723, ewa inertia: 0.002887
Minibatch iteration 161/62600: mean batch inertia: 0.002581, ewa inertia: 0.002886
Minibatch iteration 162/62600: mean batch inertia: 0.002702, ewa inertia: 0.002885
Minibatch iteration 163/62600: mean batch inertia: 0.002586, ewa inertia: 0.002884
Minibatch iteration 164/62600: mean batch inertia: 0.003026, ewa inertia: 0.002885
Minibatch iteration 165/62600: mean batch inertia: 0.002700, ewa inertia: 0.002884
Minibatch iteration 166/62600: mean batch inertia: 0.002658, ewa inertia: 0.002883
Minibatch iteration 167/62600: mean batch inertia: 0.002907, ewa inertia: 0.002883
Minibatch iteration 168/62600: mean batch inertia: 0.002692, ewa inertia: 0.002883
Minibatch iteration 169/62600: mean batch inertia: 0.002723, ewa inertia: 0.002882
Minibatch iteration 170/62600: mean batch inertia: 0.002702, ewa inertia: 0.002882
Minibatch iteration 171/62600: mean batch inertia: 0.002546, ewa inertia: 0.002881
Minibatch iteration 172/62600: mean batch inertia: 0.002900, ewa inertia: 0.002881
Minibatch iteration 173/62600: mean batch inertia: 0.002710, ewa inertia: 0.002880
Minibatch iteration 174/62600: mean batch inertia: 0.002622, ewa inertia: 0.002879
Minibatch iteration 175/62600: mean batch inertia: 0.002767, ewa inertia: 0.002879
Minibatch iteration 176/62600: mean batch inertia: 0.002772, ewa inertia: 0.002879
Minibatch iteration 177/62600: mean batch inertia: 0.002744, ewa inertia: 0.002878
Minibatch iteration 178/62600: mean batch inertia: 0.002695, ewa inertia: 0.002878
Minibatch iteration 179/62600: mean batch inertia: 0.002548, ewa inertia: 0.002877
Minibatch iteration 180/62600: mean batch inertia: 0.002593, ewa inertia: 0.002876
Minibatch iteration 181/62600: mean batch inertia: 0.002489, ewa inertia: 0.002874
Minibatch iteration 182/62600: mean batch inertia: 0.002637, ewa inertia: 0.002874
Minibatch iteration 183/62600: mean batch inertia: 0.002732, ewa inertia: 0.002873
Minibatch iteration 184/62600: mean batch inertia: 0.002703, ewa inertia: 0.002873
Minibatch iteration 185/62600: mean batch inertia: 0.002658, ewa inertia: 0.002872
Minibatch iteration 186/62600: mean batch inertia: 0.002607, ewa inertia: 0.002871
Minibatch iteration 187/62600: mean batch inertia: 0.002571, ewa inertia: 0.002870
Minibatch iteration 188/62600: mean batch inertia: 0.002807, ewa inertia: 0.002870
Minibatch iteration 189/62600: mean batch inertia: 0.002731, ewa inertia: 0.002870
Minibatch iteration 190/62600: mean batch inertia: 0.002888, ewa inertia: 0.002870
Minibatch iteration 191/62600: mean batch inertia: 0.002720, ewa inertia: 0.002869
Minibatch iteration 192/62600: mean batch inertia: 0.002474, ewa inertia: 0.002868
Minibatch iteration 193/62600: mean batch inertia: 0.002525, ewa inertia: 0.002867
Minibatch iteration 194/62600: mean batch inertia: 0.002589, ewa inertia: 0.002866
Minibatch iteration 195/62600: mean batch inertia: 0.002424, ewa inertia: 0.002864
Minibatch iteration 196/62600: mean batch inertia: 0.002734, ewa inertia: 0.002864
Minibatch iteration 197/62600: mean batch inertia: 0.002634, ewa inertia: 0.002863
Minibatch iteration 198/62600: mean batch inertia: 0.002686, ewa inertia: 0.002863
Minibatch iteration 199/62600: mean batch inertia: 0.002504, ewa inertia: 0.002862
Minibatch iteration 200/62600: mean batch inertia: 0.002770, ewa inertia: 0.002861
Minibatch iteration 201/62600: mean batch inertia: 0.002590, ewa inertia: 0.002860
Minibatch iteration 202/62600: mean batch inertia: 0.002673, ewa inertia: 0.002860
Minibatch iteration 203/62600: mean batch inertia: 0.002867, ewa inertia: 0.002860
Minibatch iteration 204/62600: mean batch inertia: 0.002848, ewa inertia: 0.002860
Minibatch iteration 205/62600: mean batch inertia: 0.002595, ewa inertia: 0.002859
Minibatch iteration 206/62600: mean batch inertia: 0.002476, ewa inertia: 0.002858
Minibatch iteration 207/62600: mean batch inertia: 0.002629, ewa inertia: 0.002857
Minibatch iteration 208/62600: mean batch inertia: 0.002542, ewa inertia: 0.002856
Minibatch iteration 209/62600: mean batch inertia: 0.002579, ewa inertia: 0.002855
Minibatch iteration 210/62600: mean batch inertia: 0.002835, ewa inertia: 0.002855
Minibatch iteration 211/62600: mean batch inertia: 0.002686, ewa inertia: 0.002855
Minibatch iteration 212/62600: mean batch inertia: 0.002645, ewa inertia: 0.002854
[MiniBatchKMeans] Reassigning 38 cluster centers.
Minibatch iteration 213/62600: mean batch inertia: 0.002649, ewa inertia: 0.002853
Minibatch iteration 214/62600: mean batch inertia: 0.002623, ewa inertia: 0.002852
Minibatch iteration 215/62600: mean batch inertia: 0.002662, ewa inertia: 0.002852
Minibatch iteration 216/62600: mean batch inertia: 0.002712, ewa inertia: 0.002851
Minibatch iteration 217/62600: mean batch inertia: 0.002870, ewa inertia: 0.002851
Minibatch iteration 218/62600: mean batch inertia: 0.002437, ewa inertia: 0.002850
Minibatch iteration 219/62600: mean batch inertia: 0.002786, ewa inertia: 0.002850
Minibatch iteration 220/62600: mean batch inertia: 0.002844, ewa inertia: 0.002850
Minibatch iteration 221/62600: mean batch inertia: 0.002673, ewa inertia: 0.002849
Minibatch iteration 222/62600: mean batch inertia: 0.002748, ewa inertia: 0.002849
Minibatch iteration 223/62600: mean batch inertia: 0.002732, ewa inertia: 0.002849
Minibatch iteration 224/62600: mean batch inertia: 0.002790, ewa inertia: 0.002848
Minibatch iteration 225/62600: mean batch inertia: 0.002587, ewa inertia: 0.002848
Minibatch iteration 226/62600: mean batch inertia: 0.002698, ewa inertia: 0.002847
Minibatch iteration 227/62600: mean batch inertia: 0.002569, ewa inertia: 0.002846
Minibatch iteration 228/62600: mean batch inertia: 0.002680, ewa inertia: 0.002846
Minibatch iteration 229/62600: mean batch inertia: 0.002740, ewa inertia: 0.002845
Minibatch iteration 230/62600: mean batch inertia: 0.002612, ewa inertia: 0.002845
Minibatch iteration 231/62600: mean batch inertia: 0.002605, ewa inertia: 0.002844
Minibatch iteration 232/62600: mean batch inertia: 0.002487, ewa inertia: 0.002843
Minibatch iteration 233/62600: mean batch inertia: 0.002732, ewa inertia: 0.002842
Minibatch iteration 234/62600: mean batch inertia: 0.002792, ewa inertia: 0.002842
Minibatch iteration 235/62600: mean batch inertia: 0.002766, ewa inertia: 0.002842
Minibatch iteration 236/62600: mean batch inertia: 0.002740, ewa inertia: 0.002842
Minibatch iteration 237/62600: mean batch inertia: 0.002690, ewa inertia: 0.002841
Minibatch iteration 238/62600: mean batch inertia: 0.002988, ewa inertia: 0.002842
Minibatch iteration 239/62600: mean batch inertia: 0.002721, ewa inertia: 0.002841
Minibatch iteration 240/62600: mean batch inertia: 0.002608, ewa inertia: 0.002841
Minibatch iteration 241/62600: mean batch inertia: 0.002615, ewa inertia: 0.002840
Minibatch iteration 242/62600: mean batch inertia: 0.002694, ewa inertia: 0.002839
Minibatch iteration 243/62600: mean batch inertia: 0.002844, ewa inertia: 0.002839
Minibatch iteration 244/62600: mean batch inertia: 0.002832, ewa inertia: 0.002839
Minibatch iteration 245/62600: mean batch inertia: 0.002834, ewa inertia: 0.002839
Minibatch iteration 246/62600: mean batch inertia: 0.002737, ewa inertia: 0.002839
Minibatch iteration 247/62600: mean batch inertia: 0.002652, ewa inertia: 0.002838
Minibatch iteration 248/62600: mean batch inertia: 0.002670, ewa inertia: 0.002838
Minibatch iteration 249/62600: mean batch inertia: 0.002661, ewa inertia: 0.002837
Minibatch iteration 250/62600: mean batch inertia: 0.002724, ewa inertia: 0.002837
Minibatch iteration 251/62600: mean batch inertia: 0.002704, ewa inertia: 0.002836
Minibatch iteration 252/62600: mean batch inertia: 0.002841, ewa inertia: 0.002836
Minibatch iteration 253/62600: mean batch inertia: 0.002767, ewa inertia: 0.002836
Minibatch iteration 254/62600: mean batch inertia: 0.002589, ewa inertia: 0.002835
Minibatch iteration 255/62600: mean batch inertia: 0.002607, ewa inertia: 0.002835
Minibatch iteration 256/62600: mean batch inertia: 0.002413, ewa inertia: 0.002833
Minibatch iteration 257/62600: mean batch inertia: 0.002653, ewa inertia: 0.002833
Minibatch iteration 258/62600: mean batch inertia: 0.002604, ewa inertia: 0.002832
Minibatch iteration 259/62600: mean batch inertia: 0.002772, ewa inertia: 0.002832
Minibatch iteration 260/62600: mean batch inertia: 0.002556, ewa inertia: 0.002831
Minibatch iteration 261/62600: mean batch inertia: 0.002815, ewa inertia: 0.002831
Minibatch iteration 262/62600: mean batch inertia: 0.002522, ewa inertia: 0.002830
Minibatch iteration 263/62600: mean batch inertia: 0.002827, ewa inertia: 0.002830
Minibatch iteration 264/62600: mean batch inertia: 0.002895, ewa inertia: 0.002830
Minibatch iteration 265/62600: mean batch inertia: 0.002723, ewa inertia: 0.002830
Minibatch iteration 266/62600: mean batch inertia: 0.002759, ewa inertia: 0.002830
Minibatch iteration 267/62600: mean batch inertia: 0.002752, ewa inertia: 0.002829
Minibatch iteration 268/62600: mean batch inertia: 0.002453, ewa inertia: 0.002828
Minibatch iteration 269/62600: mean batch inertia: 0.002540, ewa inertia: 0.002827
Minibatch iteration 270/62600: mean batch inertia: 0.002599, ewa inertia: 0.002826
Minibatch iteration 271/62600: mean batch inertia: 0.002616, ewa inertia: 0.002826
Minibatch iteration 272/62600: mean batch inertia: 0.002711, ewa inertia: 0.002825
Minibatch iteration 273/62600: mean batch inertia: 0.002898, ewa inertia: 0.002826
Minibatch iteration 274/62600: mean batch inertia: 0.002834, ewa inertia: 0.002826
Minibatch iteration 275/62600: mean batch inertia: 0.002557, ewa inertia: 0.002825
Minibatch iteration 276/62600: mean batch inertia: 0.002662, ewa inertia: 0.002824
Minibatch iteration 277/62600: mean batch inertia: 0.002471, ewa inertia: 0.002823
Minibatch iteration 278/62600: mean batch inertia: 0.002863, ewa inertia: 0.002823
Minibatch iteration 279/62600: mean batch inertia: 0.002596, ewa inertia: 0.002823
Minibatch iteration 280/62600: mean batch inertia: 0.002530, ewa inertia: 0.002822
Minibatch iteration 281/62600: mean batch inertia: 0.002750, ewa inertia: 0.002821
Minibatch iteration 282/62600: mean batch inertia: 0.002525, ewa inertia: 0.002820
Minibatch iteration 283/62600: mean batch inertia: 0.002912, ewa inertia: 0.002821
Minibatch iteration 284/62600: mean batch inertia: 0.002834, ewa inertia: 0.002821
Minibatch iteration 285/62600: mean batch inertia: 0.002871, ewa inertia: 0.002821
Minibatch iteration 286/62600: mean batch inertia: 0.002708, ewa inertia: 0.002821
Minibatch iteration 287/62600: mean batch inertia: 0.002796, ewa inertia: 0.002821
Minibatch iteration 288/62600: mean batch inertia: 0.002673, ewa inertia: 0.002820
Minibatch iteration 289/62600: mean batch inertia: 0.002770, ewa inertia: 0.002820
Minibatch iteration 290/62600: mean batch inertia: 0.002676, ewa inertia: 0.002819
Minibatch iteration 291/62600: mean batch inertia: 0.002574, ewa inertia: 0.002819
Minibatch iteration 292/62600: mean batch inertia: 0.002901, ewa inertia: 0.002819
Minibatch iteration 293/62600: mean batch inertia: 0.002706, ewa inertia: 0.002819
Minibatch iteration 294/62600: mean batch inertia: 0.002689, ewa inertia: 0.002818
Minibatch iteration 295/62600: mean batch inertia: 0.002708, ewa inertia: 0.002818
Minibatch iteration 296/62600: mean batch inertia: 0.002639, ewa inertia: 0.002817
Minibatch iteration 297/62600: mean batch inertia: 0.002587, ewa inertia: 0.002816
Minibatch iteration 298/62600: mean batch inertia: 0.002648, ewa inertia: 0.002816
Minibatch iteration 299/62600: mean batch inertia: 0.002875, ewa inertia: 0.002816
Minibatch iteration 300/62600: mean batch inertia: 0.002714, ewa inertia: 0.002816
Minibatch iteration 301/62600: mean batch inertia: 0.002516, ewa inertia: 0.002815
Minibatch iteration 302/62600: mean batch inertia: 0.002635, ewa inertia: 0.002814
Minibatch iteration 303/62600: mean batch inertia: 0.002749, ewa inertia: 0.002814
Minibatch iteration 304/62600: mean batch inertia: 0.002326, ewa inertia: 0.002813
Minibatch iteration 305/62600: mean batch inertia: 0.002648, ewa inertia: 0.002812
Minibatch iteration 306/62600: mean batch inertia: 0.002680, ewa inertia: 0.002812
Minibatch iteration 307/62600: mean batch inertia: 0.002627, ewa inertia: 0.002811
Minibatch iteration 308/62600: mean batch inertia: 0.002733, ewa inertia: 0.002811
Minibatch iteration 309/62600: mean batch inertia: 0.002694, ewa inertia: 0.002810
Minibatch iteration 310/62600: mean batch inertia: 0.002617, ewa inertia: 0.002810
Minibatch iteration 311/62600: mean batch inertia: 0.002807, ewa inertia: 0.002810
Minibatch iteration 312/62600: mean batch inertia: 0.002896, ewa inertia: 0.002810
Minibatch iteration 313/62600: mean batch inertia: 0.002544, ewa inertia: 0.002809
Minibatch iteration 314/62600: mean batch inertia: 0.002577, ewa inertia: 0.002808
Minibatch iteration 315/62600: mean batch inertia: 0.002573, ewa inertia: 0.002808
Minibatch iteration 316/62600: mean batch inertia: 0.002382, ewa inertia: 0.002806
Minibatch iteration 317/62600: mean batch inertia: 0.002561, ewa inertia: 0.002806
Minibatch iteration 318/62600: mean batch inertia: 0.002625, ewa inertia: 0.002805
Minibatch iteration 319/62600: mean batch inertia: 0.002783, ewa inertia: 0.002805
Minibatch iteration 320/62600: mean batch inertia: 0.002695, ewa inertia: 0.002805
Minibatch iteration 321/62600: mean batch inertia: 0.002664, ewa inertia: 0.002804
Minibatch iteration 322/62600: mean batch inertia: 0.002786, ewa inertia: 0.002804
Minibatch iteration 323/62600: mean batch inertia: 0.002703, ewa inertia: 0.002804
Minibatch iteration 324/62600: mean batch inertia: 0.002767, ewa inertia: 0.002804
Minibatch iteration 325/62600: mean batch inertia: 0.002675, ewa inertia: 0.002803
Minibatch iteration 326/62600: mean batch inertia: 0.002489, ewa inertia: 0.002802
Minibatch iteration 327/62600: mean batch inertia: 0.002705, ewa inertia: 0.002802
Minibatch iteration 328/62600: mean batch inertia: 0.002759, ewa inertia: 0.002802
Minibatch iteration 329/62600: mean batch inertia: 0.002595, ewa inertia: 0.002801
Minibatch iteration 330/62600: mean batch inertia: 0.002581, ewa inertia: 0.002800
Minibatch iteration 331/62600: mean batch inertia: 0.002845, ewa inertia: 0.002800
Minibatch iteration 332/62600: mean batch inertia: 0.002569, ewa inertia: 0.002800
Minibatch iteration 333/62600: mean batch inertia: 0.002793, ewa inertia: 0.002800
Minibatch iteration 334/62600: mean batch inertia: 0.002906, ewa inertia: 0.002800
Minibatch iteration 335/62600: mean batch inertia: 0.002756, ewa inertia: 0.002800
Minibatch iteration 336/62600: mean batch inertia: 0.002705, ewa inertia: 0.002800
Minibatch iteration 337/62600: mean batch inertia: 0.002651, ewa inertia: 0.002799
Minibatch iteration 338/62600: mean batch inertia: 0.002662, ewa inertia: 0.002799
Minibatch iteration 339/62600: mean batch inertia: 0.002695, ewa inertia: 0.002798
Minibatch iteration 340/62600: mean batch inertia: 0.002599, ewa inertia: 0.002798
Minibatch iteration 341/62600: mean batch inertia: 0.002628, ewa inertia: 0.002797
Minibatch iteration 342/62600: mean batch inertia: 0.002686, ewa inertia: 0.002797
Minibatch iteration 343/62600: mean batch inertia: 0.002664, ewa inertia: 0.002796
Minibatch iteration 344/62600: mean batch inertia: 0.002995, ewa inertia: 0.002797
[MiniBatchKMeans] Reassigning 36 cluster centers.
Minibatch iteration 345/62600: mean batch inertia: 0.002610, ewa inertia: 0.002796
Minibatch iteration 346/62600: mean batch inertia: 0.002710, ewa inertia: 0.002796
Minibatch iteration 347/62600: mean batch inertia: 0.002872, ewa inertia: 0.002796
Minibatch iteration 348/62600: mean batch inertia: 0.002966, ewa inertia: 0.002797
Minibatch iteration 349/62600: mean batch inertia: 0.002891, ewa inertia: 0.002797
Minibatch iteration 350/62600: mean batch inertia: 0.002549, ewa inertia: 0.002796
Minibatch iteration 351/62600: mean batch inertia: 0.002757, ewa inertia: 0.002796
Minibatch iteration 352/62600: mean batch inertia: 0.002467, ewa inertia: 0.002795
Minibatch iteration 353/62600: mean batch inertia: 0.002542, ewa inertia: 0.002794
Minibatch iteration 354/62600: mean batch inertia: 0.002673, ewa inertia: 0.002794
Minibatch iteration 355/62600: mean batch inertia: 0.002440, ewa inertia: 0.002793
Minibatch iteration 356/62600: mean batch inertia: 0.002736, ewa inertia: 0.002793
Minibatch iteration 357/62600: mean batch inertia: 0.002696, ewa inertia: 0.002792
Minibatch iteration 358/62600: mean batch inertia: 0.002684, ewa inertia: 0.002792
Minibatch iteration 359/62600: mean batch inertia: 0.002312, ewa inertia: 0.002791
Minibatch iteration 360/62600: mean batch inertia: 0.002652, ewa inertia: 0.002790
Minibatch iteration 361/62600: mean batch inertia: 0.002970, ewa inertia: 0.002791
Minibatch iteration 362/62600: mean batch inertia: 0.002802, ewa inertia: 0.002791
Minibatch iteration 363/62600: mean batch inertia: 0.002739, ewa inertia: 0.002791
Minibatch iteration 364/62600: mean batch inertia: 0.002636, ewa inertia: 0.002790
Minibatch iteration 365/62600: mean batch inertia: 0.002732, ewa inertia: 0.002790
Minibatch iteration 366/62600: mean batch inertia: 0.002584, ewa inertia: 0.002789
Minibatch iteration 367/62600: mean batch inertia: 0.002870, ewa inertia: 0.002789
Minibatch iteration 368/62600: mean batch inertia: 0.002681, ewa inertia: 0.002789
Minibatch iteration 369/62600: mean batch inertia: 0.002880, ewa inertia: 0.002789
Minibatch iteration 370/62600: mean batch inertia: 0.002803, ewa inertia: 0.002789
Minibatch iteration 371/62600: mean batch inertia: 0.002821, ewa inertia: 0.002790
Minibatch iteration 372/62600: mean batch inertia: 0.002831, ewa inertia: 0.002790
Minibatch iteration 373/62600: mean batch inertia: 0.002831, ewa inertia: 0.002790
Minibatch iteration 374/62600: mean batch inertia: 0.002461, ewa inertia: 0.002789
Minibatch iteration 375/62600: mean batch inertia: 0.002497, ewa inertia: 0.002788
Minibatch iteration 376/62600: mean batch inertia: 0.002830, ewa inertia: 0.002788
Minibatch iteration 377/62600: mean batch inertia: 0.002560, ewa inertia: 0.002787
Minibatch iteration 378/62600: mean batch inertia: 0.002645, ewa inertia: 0.002787
Minibatch iteration 379/62600: mean batch inertia: 0.002674, ewa inertia: 0.002786
Minibatch iteration 380/62600: mean batch inertia: 0.002604, ewa inertia: 0.002786
Minibatch iteration 381/62600: mean batch inertia: 0.002823, ewa inertia: 0.002786
Minibatch iteration 382/62600: mean batch inertia: 0.002769, ewa inertia: 0.002786
Minibatch iteration 383/62600: mean batch inertia: 0.002565, ewa inertia: 0.002785
Minibatch iteration 384/62600: mean batch inertia: 0.002878, ewa inertia: 0.002786
Minibatch iteration 385/62600: mean batch inertia: 0.002644, ewa inertia: 0.002785
Minibatch iteration 386/62600: mean batch inertia: 0.002767, ewa inertia: 0.002785
Minibatch iteration 387/62600: mean batch inertia: 0.002701, ewa inertia: 0.002785
Minibatch iteration 388/62600: mean batch inertia: 0.002606, ewa inertia: 0.002784
Minibatch iteration 389/62600: mean batch inertia: 0.002762, ewa inertia: 0.002784
Minibatch iteration 390/62600: mean batch inertia: 0.002792, ewa inertia: 0.002784
Minibatch iteration 391/62600: mean batch inertia: 0.002597, ewa inertia: 0.002784
Minibatch iteration 392/62600: mean batch inertia: 0.002682, ewa inertia: 0.002783
Minibatch iteration 393/62600: mean batch inertia: 0.002704, ewa inertia: 0.002783
Minibatch iteration 394/62600: mean batch inertia: 0.002639, ewa inertia: 0.002782
Minibatch iteration 395/62600: mean batch inertia: 0.002703, ewa inertia: 0.002782
Minibatch iteration 396/62600: mean batch inertia: 0.002338, ewa inertia: 0.002781
Minibatch iteration 397/62600: mean batch inertia: 0.002810, ewa inertia: 0.002781
Minibatch iteration 398/62600: mean batch inertia: 0.002684, ewa inertia: 0.002781
Minibatch iteration 399/62600: mean batch inertia: 0.002681, ewa inertia: 0.002780
Minibatch iteration 400/62600: mean batch inertia: 0.002810, ewa inertia: 0.002780
Minibatch iteration 401/62600: mean batch inertia: 0.002670, ewa inertia: 0.002780
Minibatch iteration 402/62600: mean batch inertia: 0.002607, ewa inertia: 0.002779
Minibatch iteration 403/62600: mean batch inertia: 0.002700, ewa inertia: 0.002779
Minibatch iteration 404/62600: mean batch inertia: 0.002591, ewa inertia: 0.002779
Minibatch iteration 405/62600: mean batch inertia: 0.002526, ewa inertia: 0.002778
Minibatch iteration 406/62600: mean batch inertia: 0.002607, ewa inertia: 0.002777
Minibatch iteration 407/62600: mean batch inertia: 0.002631, ewa inertia: 0.002777
Minibatch iteration 408/62600: mean batch inertia: 0.002614, ewa inertia: 0.002776
Minibatch iteration 409/62600: mean batch inertia: 0.002909, ewa inertia: 0.002777
Minibatch iteration 410/62600: mean batch inertia: 0.002539, ewa inertia: 0.002776
Minibatch iteration 411/62600: mean batch inertia: 0.002518, ewa inertia: 0.002775
Minibatch iteration 412/62600: mean batch inertia: 0.002710, ewa inertia: 0.002775
Minibatch iteration 413/62600: mean batch inertia: 0.002643, ewa inertia: 0.002774
Minibatch iteration 414/62600: mean batch inertia: 0.002505, ewa inertia: 0.002774
Minibatch iteration 415/62600: mean batch inertia: 0.002681, ewa inertia: 0.002773
Minibatch iteration 416/62600: mean batch inertia: 0.002851, ewa inertia: 0.002774
Minibatch iteration 417/62600: mean batch inertia: 0.002462, ewa inertia: 0.002773
Minibatch iteration 418/62600: mean batch inertia: 0.002485, ewa inertia: 0.002772
Minibatch iteration 419/62600: mean batch inertia: 0.002678, ewa inertia: 0.002771
Minibatch iteration 420/62600: mean batch inertia: 0.002647, ewa inertia: 0.002771
Minibatch iteration 421/62600: mean batch inertia: 0.002888, ewa inertia: 0.002771
Minibatch iteration 422/62600: mean batch inertia: 0.002744, ewa inertia: 0.002771
Minibatch iteration 423/62600: mean batch inertia: 0.002787, ewa inertia: 0.002771
Minibatch iteration 424/62600: mean batch inertia: 0.002922, ewa inertia: 0.002772
Minibatch iteration 425/62600: mean batch inertia: 0.002699, ewa inertia: 0.002772
Minibatch iteration 426/62600: mean batch inertia: 0.002727, ewa inertia: 0.002771
Minibatch iteration 427/62600: mean batch inertia: 0.002833, ewa inertia: 0.002772
Minibatch iteration 428/62600: mean batch inertia: 0.002510, ewa inertia: 0.002771
Minibatch iteration 429/62600: mean batch inertia: 0.002876, ewa inertia: 0.002771
Minibatch iteration 430/62600: mean batch inertia: 0.002707, ewa inertia: 0.002771
Minibatch iteration 431/62600: mean batch inertia: 0.002545, ewa inertia: 0.002770
Minibatch iteration 432/62600: mean batch inertia: 0.002535, ewa inertia: 0.002769
Minibatch iteration 433/62600: mean batch inertia: 0.002531, ewa inertia: 0.002769
Minibatch iteration 434/62600: mean batch inertia: 0.002679, ewa inertia: 0.002768
Minibatch iteration 435/62600: mean batch inertia: 0.002725, ewa inertia: 0.002768
Minibatch iteration 436/62600: mean batch inertia: 0.002835, ewa inertia: 0.002768
Minibatch iteration 437/62600: mean batch inertia: 0.002470, ewa inertia: 0.002767
Minibatch iteration 438/62600: mean batch inertia: 0.002706, ewa inertia: 0.002767
Minibatch iteration 439/62600: mean batch inertia: 0.002609, ewa inertia: 0.002767
Minibatch iteration 440/62600: mean batch inertia: 0.002711, ewa inertia: 0.002767
Minibatch iteration 441/62600: mean batch inertia: 0.002650, ewa inertia: 0.002766
Minibatch iteration 442/62600: mean batch inertia: 0.002667, ewa inertia: 0.002766
Minibatch iteration 443/62600: mean batch inertia: 0.002478, ewa inertia: 0.002765
Minibatch iteration 444/62600: mean batch inertia: 0.002666, ewa inertia: 0.002765
Minibatch iteration 445/62600: mean batch inertia: 0.002460, ewa inertia: 0.002764
Minibatch iteration 446/62600: mean batch inertia: 0.002576, ewa inertia: 0.002763
Minibatch iteration 447/62600: mean batch inertia: 0.003037, ewa inertia: 0.002764
Minibatch iteration 448/62600: mean batch inertia: 0.002487, ewa inertia: 0.002763
Minibatch iteration 449/62600: mean batch inertia: 0.002677, ewa inertia: 0.002763
Minibatch iteration 450/62600: mean batch inertia: 0.002601, ewa inertia: 0.002762
Minibatch iteration 451/62600: mean batch inertia: 0.002624, ewa inertia: 0.002762
Minibatch iteration 452/62600: mean batch inertia: 0.002526, ewa inertia: 0.002761
Minibatch iteration 453/62600: mean batch inertia: 0.002462, ewa inertia: 0.002760
Minibatch iteration 454/62600: mean batch inertia: 0.002864, ewa inertia: 0.002760
Minibatch iteration 455/62600: mean batch inertia: 0.002902, ewa inertia: 0.002761
Minibatch iteration 456/62600: mean batch inertia: 0.002457, ewa inertia: 0.002760
Minibatch iteration 457/62600: mean batch inertia: 0.002653, ewa inertia: 0.002760
Minibatch iteration 458/62600: mean batch inertia: 0.002529, ewa inertia: 0.002759
Minibatch iteration 459/62600: mean batch inertia: 0.002750, ewa inertia: 0.002759
Minibatch iteration 460/62600: mean batch inertia: 0.002745, ewa inertia: 0.002759
Minibatch iteration 461/62600: mean batch inertia: 0.002555, ewa inertia: 0.002758
[MiniBatchKMeans] Reassigning 37 cluster centers.
Minibatch iteration 462/62600: mean batch inertia: 0.002612, ewa inertia: 0.002758
Minibatch iteration 463/62600: mean batch inertia: 0.002730, ewa inertia: 0.002758
Minibatch iteration 464/62600: mean batch inertia: 0.002649, ewa inertia: 0.002757
Minibatch iteration 465/62600: mean batch inertia: 0.002656, ewa inertia: 0.002757
Minibatch iteration 466/62600: mean batch inertia: 0.002757, ewa inertia: 0.002757
Minibatch iteration 467/62600: mean batch inertia: 0.002830, ewa inertia: 0.002757
Minibatch iteration 468/62600: mean batch inertia: 0.002481, ewa inertia: 0.002756
Minibatch iteration 469/62600: mean batch inertia: 0.002704, ewa inertia: 0.002756
Minibatch iteration 470/62600: mean batch inertia: 0.002559, ewa inertia: 0.002755
Minibatch iteration 471/62600: mean batch inertia: 0.002520, ewa inertia: 0.002755
Minibatch iteration 472/62600: mean batch inertia: 0.002766, ewa inertia: 0.002755
Minibatch iteration 473/62600: mean batch inertia: 0.002751, ewa inertia: 0.002755
Minibatch iteration 474/62600: mean batch inertia: 0.002766, ewa inertia: 0.002755
Minibatch iteration 475/62600: mean batch inertia: 0.002634, ewa inertia: 0.002754
Minibatch iteration 476/62600: mean batch inertia: 0.002693, ewa inertia: 0.002754
Minibatch iteration 477/62600: mean batch inertia: 0.002636, ewa inertia: 0.002754
Minibatch iteration 478/62600: mean batch inertia: 0.002450, ewa inertia: 0.002753
Minibatch iteration 479/62600: mean batch inertia: 0.002452, ewa inertia: 0.002752
Minibatch iteration 480/62600: mean batch inertia: 0.002729, ewa inertia: 0.002752
Minibatch iteration 481/62600: mean batch inertia: 0.002862, ewa inertia: 0.002752
Minibatch iteration 482/62600: mean batch inertia: 0.002872, ewa inertia: 0.002753
Minibatch iteration 483/62600: mean batch inertia: 0.002722, ewa inertia: 0.002752
Minibatch iteration 484/62600: mean batch inertia: 0.002747, ewa inertia: 0.002752
Minibatch iteration 485/62600: mean batch inertia: 0.002618, ewa inertia: 0.002752
Minibatch iteration 486/62600: mean batch inertia: 0.003006, ewa inertia: 0.002753
Minibatch iteration 487/62600: mean batch inertia: 0.002648, ewa inertia: 0.002752
Minibatch iteration 488/62600: mean batch inertia: 0.002802, ewa inertia: 0.002753
Minibatch iteration 489/62600: mean batch inertia: 0.002633, ewa inertia: 0.002752
Minibatch iteration 490/62600: mean batch inertia: 0.002540, ewa inertia: 0.002752
Minibatch iteration 491/62600: mean batch inertia: 0.002743, ewa inertia: 0.002752
Minibatch iteration 492/62600: mean batch inertia: 0.002705, ewa inertia: 0.002751
Minibatch iteration 493/62600: mean batch inertia: 0.002843, ewa inertia: 0.002752
Minibatch iteration 494/62600: mean batch inertia: 0.002820, ewa inertia: 0.002752
Minibatch iteration 495/62600: mean batch inertia: 0.002658, ewa inertia: 0.002752
Minibatch iteration 496/62600: mean batch inertia: 0.002684, ewa inertia: 0.002751
Minibatch iteration 497/62600: mean batch inertia: 0.002602, ewa inertia: 0.002751
Minibatch iteration 498/62600: mean batch inertia: 0.002922, ewa inertia: 0.002751
Minibatch iteration 499/62600: mean batch inertia: 0.002773, ewa inertia: 0.002752
Minibatch iteration 500/62600: mean batch inertia: 0.002498, ewa inertia: 0.002751
Minibatch iteration 501/62600: mean batch inertia: 0.002511, ewa inertia: 0.002750
Minibatch iteration 502/62600: mean batch inertia: 0.002810, ewa inertia: 0.002750
Minibatch iteration 503/62600: mean batch inertia: 0.002635, ewa inertia: 0.002750
Minibatch iteration 504/62600: mean batch inertia: 0.002794, ewa inertia: 0.002750
Minibatch iteration 505/62600: mean batch inertia: 0.002675, ewa inertia: 0.002750
Minibatch iteration 506/62600: mean batch inertia: 0.002865, ewa inertia: 0.002750
Minibatch iteration 507/62600: mean batch inertia: 0.002808, ewa inertia: 0.002750
Minibatch iteration 508/62600: mean batch inertia: 0.002758, ewa inertia: 0.002750
Minibatch iteration 509/62600: mean batch inertia: 0.002671, ewa inertia: 0.002750
Minibatch iteration 510/62600: mean batch inertia: 0.002894, ewa inertia: 0.002750
Minibatch iteration 511/62600: mean batch inertia: 0.002621, ewa inertia: 0.002750
Minibatch iteration 512/62600: mean batch inertia: 0.002756, ewa inertia: 0.002750
Minibatch iteration 513/62600: mean batch inertia: 0.002692, ewa inertia: 0.002750
Minibatch iteration 514/62600: mean batch inertia: 0.002874, ewa inertia: 0.002750
Minibatch iteration 515/62600: mean batch inertia: 0.002608, ewa inertia: 0.002750
Converged (lack of improvement in inertia) at iteration 515/62600
Computing label assignment and total inertia
____________________________________________________estimator_fit - 1.2s, 0.0min
KMeans 50 clusters: 47.67s

8.4.12.7. Visualize: Brain parcellations (KMeans)

Grab parcellations of brain image stored in attribute labels_img_

kmeans_labels_img = kmeans.labels_img_

plotting.plot_roi(kmeans_labels_img, mean_func_img,
                  title="KMeans parcellation",
                  display_mode='xz')

# kmeans_labels_img is a Nifti1Image object, it can be saved to file with
# the following code:
kmeans_labels_img.to_filename('kmeans_parcellation.nii.gz')
../../_images/sphx_glr_plot_rest_parcellations_004.png

Finally show them

Total running time of the script: ( 1 minutes 12.719 seconds)

Generated by Sphinx-Gallery