.. _sphx_glr_auto_examples_cluster: .. _cluster_examples: Clustering ---------- Examples concerning the :mod:`sklearn.cluster` module. .. raw:: html <div class="sphx-glr-thumbnails"> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="In this example we compare the various initialization strategies for K-means in terms of runtim..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_kmeans_digits_thumb.png :alt: A demo of K-Means clustering on the handwritten digits data :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_digits.py` .. raw:: html <div class="sphx-glr-thumbnail-title">A demo of K-Means clustering on the handwritten digits data</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Compute the segmentation of a 2D image with Ward hierarchical clustering. The clustering is spa..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_coin_ward_segmentation_thumb.png :alt: A demo of structured Ward hierarchical clustering on an image of coins :ref:`sphx_glr_auto_examples_cluster_plot_coin_ward_segmentation.py` .. raw:: html <div class="sphx-glr-thumbnail-title">A demo of structured Ward hierarchical clustering on an image of coins</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Reference:"> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_mean_shift_thumb.png :alt: A demo of the mean-shift clustering algorithm :ref:`sphx_glr_auto_examples_cluster_plot_mean_shift.py` .. raw:: html <div class="sphx-glr-thumbnail-title">A demo of the mean-shift clustering algorithm</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="- a first experiment with fixed "ground truth labels" (and therefore fixed number of classes)..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_adjusted_for_chance_measures_thumb.png :alt: Adjustment for chance in clustering performance evaluation :ref:`sphx_glr_auto_examples_cluster_plot_adjusted_for_chance_measures.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Adjustment for chance in clustering performance evaluation</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example shows the effect of imposing a connectivity graph to capture local structure in th..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_agglomerative_clustering_thumb.png :alt: Agglomerative clustering with and without structure :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_clustering.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Agglomerative clustering with and without structure</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates the effect of different metrics on the hierarchical clustering."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_agglomerative_clustering_metrics_thumb.png :alt: Agglomerative clustering with different metrics :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_clustering_metrics.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Agglomerative clustering with different metrics</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="An example to show the output of the sklearn.cluster.kmeans_plusplus function for generating in..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_kmeans_plusplus_thumb.png :alt: An example of K-Means++ initialization :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_plusplus.py` .. raw:: html <div class="sphx-glr-thumbnail-title">An example of K-Means++ initialization</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example shows differences between Regular K-Means algorithm and Bisecting K-Means."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_bisect_kmeans_thumb.png :alt: Bisecting K-Means and Regular K-Means Performance Comparison :ref:`sphx_glr_auto_examples_cluster_plot_bisect_kmeans.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Bisecting K-Means and Regular K-Means Performance Comparison</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Performs a pixel-wise Vector Quantization (VQ) of an image of the summer palace (China), reduci..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_color_quantization_thumb.png :alt: Color Quantization using K-Means :ref:`sphx_glr_auto_examples_cluster_plot_color_quantization.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Color Quantization using K-Means</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example compares the timing of BIRCH (with and without the global clustering step) and Min..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_birch_vs_minibatchkmeans_thumb.png :alt: Compare BIRCH and MiniBatchKMeans :ref:`sphx_glr_auto_examples_cluster_plot_birch_vs_minibatchkmeans.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Compare BIRCH and MiniBatchKMeans</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example shows characteristics of different clustering algorithms on datasets that are "int..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_cluster_comparison_thumb.png :alt: Comparing different clustering algorithms on toy datasets :ref:`sphx_glr_auto_examples_cluster_plot_cluster_comparison.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Comparing different clustering algorithms on toy datasets</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example shows characteristics of different linkage methods for hierarchical clustering on ..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_linkage_comparison_thumb.png :alt: Comparing different hierarchical linkage methods on toy datasets :ref:`sphx_glr_auto_examples_cluster_plot_linkage_comparison.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Comparing different hierarchical linkage methods on toy datasets</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="We want to compare the performance of the MiniBatchKMeans and KMeans: the MiniBatchKMeans is fa..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_mini_batch_kmeans_thumb.png :alt: Comparison of the K-Means and MiniBatchKMeans clustering algorithms :ref:`sphx_glr_auto_examples_cluster_plot_mini_batch_kmeans.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Comparison of the K-Means and MiniBatchKMeans clustering algorithms</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="DBSCAN (Density-Based Spatial Clustering of Applications with Noise) finds core samples in regi..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_dbscan_thumb.png :alt: Demo of DBSCAN clustering algorithm :ref:`sphx_glr_auto_examples_cluster_plot_dbscan.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Demo of DBSCAN clustering algorithm</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Finds core samples of high density and expands clusters from them. This example uses data that ..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_optics_thumb.png :alt: Demo of OPTICS clustering algorithm :ref:`sphx_glr_auto_examples_cluster_plot_optics.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Demo of OPTICS clustering algorithm</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Reference: Brendan J. Frey and Delbert Dueck, "Clustering by Passing Messages Between Data Poin..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_affinity_propagation_thumb.png :alt: Demo of affinity propagation clustering algorithm :ref:`sphx_glr_auto_examples_cluster_plot_affinity_propagation.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Demo of affinity propagation clustering algorithm</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example is meant to illustrate situations where k-means produces unintuitive and possibly ..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_kmeans_assumptions_thumb.png :alt: Demonstration of k-means assumptions :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_assumptions.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Demonstration of k-means assumptions</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Evaluate the ability of k-means initializations strategies to make the algorithm convergence ro..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_kmeans_stability_low_dim_dense_thumb.png :alt: Empirical evaluation of the impact of k-means initialization :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_stability_low_dim_dense.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Empirical evaluation of the impact of k-means initialization</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="These images how similar features are merged together using feature agglomeration."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_digits_agglomeration_thumb.png :alt: Feature agglomeration :ref:`sphx_glr_auto_examples_cluster_plot_digits_agglomeration.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Feature agglomeration</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example compares 2 dimensionality reduction strategies:"> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_feature_agglomeration_vs_univariate_selection_thumb.png :alt: Feature agglomeration vs. univariate selection :ref:`sphx_glr_auto_examples_cluster_plot_feature_agglomeration_vs_univariate_selection.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Feature agglomeration vs. univariate selection</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Example builds a swiss roll dataset and runs hierarchical clustering on their position."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_ward_structured_vs_unstructured_thumb.png :alt: Hierarchical clustering: structured vs unstructured ward :ref:`sphx_glr_auto_examples_cluster_plot_ward_structured_vs_unstructured.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Hierarchical clustering: structured vs unstructured ward</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Clustering can be expensive, especially when our dataset contains millions of datapoints. Many ..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_inductive_clustering_thumb.png :alt: Inductive Clustering :ref:`sphx_glr_auto_examples_cluster_plot_inductive_clustering.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Inductive Clustering</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="The plot shows:"> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_cluster_iris_thumb.png :alt: K-means Clustering :ref:`sphx_glr_auto_examples_cluster_plot_cluster_iris.py` .. raw:: html <div class="sphx-glr-thumbnail-title">K-means Clustering</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example uses a large dataset of faces to learn a set of 20 x 20 images patches that consti..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_dict_face_patches_thumb.png :alt: Online learning of a dictionary of parts of faces :ref:`sphx_glr_auto_examples_cluster_plot_dict_face_patches.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Online learning of a dictionary of parts of faces</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Plot Hierarchical Clustering Dendrogram"> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_agglomerative_dendrogram_thumb.png :alt: Plot Hierarchical Clustering Dendrogram :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_dendrogram.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Plot Hierarchical Clustering Dendrogram</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example uses spectral_clustering on a graph created from voxel-to-voxel difference on an i..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_coin_segmentation_thumb.png :alt: Segmenting the picture of greek coins in regions :ref:`sphx_glr_auto_examples_cluster_plot_coin_segmentation.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Segmenting the picture of greek coins in regions</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="Silhouette analysis can be used to study the separation distance between the resulting clusters..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_kmeans_silhouette_analysis_thumb.png :alt: Selecting the number of clusters with silhouette analysis on KMeans clustering :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_silhouette_analysis.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Selecting the number of clusters with silhouette analysis on KMeans clustering</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="In this example, an image with connected circles is generated and spectral clustering is used t..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_segmentation_toy_thumb.png :alt: Spectral clustering for image segmentation :ref:`sphx_glr_auto_examples_cluster_plot_segmentation_toy.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Spectral clustering for image segmentation</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="An illustration of various linkage option for agglomerative clustering on a 2D embedding of the..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_digits_linkage_thumb.png :alt: Various Agglomerative Clustering on a 2D embedding of digits :ref:`sphx_glr_auto_examples_cluster_plot_digits_linkage.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Various Agglomerative Clustering on a 2D embedding of digits</div> </div> .. raw:: html <div class="sphx-glr-thumbcontainer" tooltip="This example shows how one can use KBinsDiscretizer to perform vector quantization on a set of ..."> .. only:: html .. image:: /auto_examples/cluster/images/thumb/sphx_glr_plot_face_compress_thumb.png :alt: Vector Quantization Example :ref:`sphx_glr_auto_examples_cluster_plot_face_compress.py` .. raw:: html <div class="sphx-glr-thumbnail-title">Vector Quantization Example</div> </div> .. raw:: html </div> .. toctree:: :hidden: /auto_examples/cluster/plot_kmeans_digits /auto_examples/cluster/plot_coin_ward_segmentation /auto_examples/cluster/plot_mean_shift /auto_examples/cluster/plot_adjusted_for_chance_measures /auto_examples/cluster/plot_agglomerative_clustering /auto_examples/cluster/plot_agglomerative_clustering_metrics /auto_examples/cluster/plot_kmeans_plusplus /auto_examples/cluster/plot_bisect_kmeans /auto_examples/cluster/plot_color_quantization /auto_examples/cluster/plot_birch_vs_minibatchkmeans /auto_examples/cluster/plot_cluster_comparison /auto_examples/cluster/plot_linkage_comparison /auto_examples/cluster/plot_mini_batch_kmeans /auto_examples/cluster/plot_dbscan /auto_examples/cluster/plot_optics /auto_examples/cluster/plot_affinity_propagation /auto_examples/cluster/plot_kmeans_assumptions /auto_examples/cluster/plot_kmeans_stability_low_dim_dense /auto_examples/cluster/plot_digits_agglomeration /auto_examples/cluster/plot_feature_agglomeration_vs_univariate_selection /auto_examples/cluster/plot_ward_structured_vs_unstructured /auto_examples/cluster/plot_inductive_clustering /auto_examples/cluster/plot_cluster_iris /auto_examples/cluster/plot_dict_face_patches /auto_examples/cluster/plot_agglomerative_dendrogram /auto_examples/cluster/plot_coin_segmentation /auto_examples/cluster/plot_kmeans_silhouette_analysis /auto_examples/cluster/plot_segmentation_toy /auto_examples/cluster/plot_digits_linkage /auto_examples/cluster/plot_face_compress