.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/bicluster/plot_spectral_coclustering.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via JupyterLite or Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_bicluster_plot_spectral_coclustering.py: ============================================== عرض توضيحي لخوارزمية التجميع الطيفي المشترك ============================================== هذا المثال يوضح كيفية إنشاء مجموعة بيانات وتجميعها باستخدام خوارزمية التجميع الطيفي المشترك. تم إنشاء مجموعة البيانات باستخدام الدالة ``make_biclusters``، والتي تنشئ مصفوفة من القيم الصغيرة وتزرع مجموعات التجميع الفرعية ذات القيم الكبيرة. يتم بعد ذلك خلط الصفوف والأعمدة وتمريرها إلى خوارزمية التجميع الطيفي المشترك. إعادة ترتيب المصفوفة المخلوطة لجعل مجموعات التجميع الفرعية متجاورة يُظهر مدى دقة الخوارزمية في العثور على مجموعات التجميع الفرعية. .. GENERATED FROM PYTHON SOURCE LINES 15-56 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_001.png :alt: Original dataset :srcset: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_002.png :alt: Shuffled dataset :srcset: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_003.png :alt: After biclustering; rearranged to show biclusters :srcset: /auto_examples/bicluster/images/sphx_glr_plot_spectral_coclustering_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none consensus score: 1.000 | .. code-block:: Python # المؤلفون: مطوري سكايلرن # معرف الترخيص: BSD-3-Clause import numpy as np from matplotlib import pyplot as plt from sklearn.cluster import SpectralCoclustering from sklearn.datasets import make_biclusters from sklearn.metrics import consensus_score data, rows, columns = make_biclusters( shape=(300, 300), n_clusters=5, noise=5, shuffle=False, random_state=0 ) plt.matshow(data, cmap=plt.cm.Blues) plt.title("Original dataset") # shuffle clusters rng = np.random.RandomState(0) row_idx = rng.permutation(data.shape[0]) col_idx = rng.permutation(data.shape[1]) data = data[row_idx][:, col_idx] plt.matshow(data, cmap=plt.cm.Blues) plt.title("Shuffled dataset") model = SpectralCoclustering(n_clusters=5, random_state=0) model.fit(data) score = consensus_score( model.biclusters_, (rows[:, row_idx], columns[:, col_idx])) print("consensus score: {:.3f}".format(score)) fit_data = data[np.argsort(model.row_labels_)] fit_data = fit_data[:, np.argsort(model.column_labels_)] plt.matshow(fit_data, cmap=plt.cm.Blues) plt.title("After biclustering; rearranged to show biclusters") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.435 seconds) .. _sphx_glr_download_auto_examples_bicluster_plot_spectral_coclustering.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-learn/scikit-learn/main?urlpath=lab/tree/notebooks/auto_examples/bicluster/plot_spectral_coclustering.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/bicluster/plot_spectral_coclustering.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_spectral_coclustering.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_spectral_coclustering.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_spectral_coclustering.zip ` .. include:: plot_spectral_coclustering.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_