.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/decomposition/plot_ica_blind_source_separation.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_decomposition_plot_ica_blind_source_separation.py: ===================================== فصل المصدر الأعمى باستخدام FastICA ===================================== مثال على تقدير المصادر من بيانات مشوشة. يتم استخدام :ref:`ICA` لتقدير المصادر في ضوء قياسات مشوشة. تخيل 3 آلات موسيقية تعزف في وقت واحد و 3 ميكروفونات تسجل الإشارات المختلطة. يتم استخدام ICA لاستعادة المصادر أي ما يتم عزفه بواسطة كل آلة. الأهم من ذلك، أن PCA يفشل في استعادة "الآلات" الخاصة بنا لأن الإشارات ذات الصلة تعكس عمليات غير غاوسية. .. GENERATED FROM PYTHON SOURCE LINES 16-20 .. code-block:: Python # Authors: The scikit-learn developers # SPDX-License-Identifier: BSD-3-Clause .. GENERATED FROM PYTHON SOURCE LINES 21-23 إنشاء بيانات نموذجية -------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-45 .. code-block:: Python import matplotlib.pyplot as plt from sklearn.decomposition import PCA, FastICA import numpy as np from scipy import signal np.random.seed(0) n_samples = 2000 time = np.linspace(0, 8, n_samples) s1 = np.sin(2 * time) # الإشارة 1: إشارة جيبية s2 = np.sign(np.sin(3 * time)) # الإشارة 2: إشارة مربعة s3 = signal.sawtooth(2 * np.pi * time) # الإشارة 3: إشارة سن المنشار S = np.c_[s1, s2, s3] S += 0.2 * np.random.normal(size=S.shape) # إضافة ضوضاء S /= S.std(axis=0) # توحيد البيانات # خلط البيانات A = np.array([[1, 1, 1], [0.5, 2, 1.0], [1.5, 1.0, 2.0]]) # مصفوفة الخلط X = np.dot(S, A.T) # إنشاء الملاحظات .. GENERATED FROM PYTHON SOURCE LINES 46-48 ملاءمة نماذج ICA و PCA ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 48-62 .. code-block:: Python # حساب ICA ica = FastICA(n_components=3, whiten="arbitrary-variance") S_ = ica.fit_transform(X) # إعادة بناء الإشارات A_ = ica.mixing_ # الحصول على مصفوفة الخلط المقدرة # يمكننا "إثبات" أن نموذج ICA ينطبق عن طريق عكس عدم الخلط. assert np.allclose(X, np.dot(S_, A_.T) + ica.mean_) # للمقارنة، حساب PCA pca = PCA(n_components=3) H = pca.fit_transform(X) # إعادة بناء الإشارات بناءً على المكونات المتعامدة .. GENERATED FROM PYTHON SOURCE LINES 63-65 رسم النتائج ------------ .. GENERATED FROM PYTHON SOURCE LINES 65-86 .. code-block:: Python plt.figure() models = [X, S, S_, H] names = [ "الملاحظات (إشارة مختلطة)", "المصادر الحقيقية", "إشارات ICA المستعادة", "إشارات PCA المستعادة", ] colors = ["red", "steelblue", "orange"] for ii, (model, name) in enumerate(zip(models, names), 1): plt.subplot(4, 1, ii) plt.title(name) for sig, color in zip(model.T, colors): plt.plot(sig, color=color) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/decomposition/images/sphx_glr_plot_ica_blind_source_separation_001.png :alt: الملاحظات (إشارة مختلطة), المصادر الحقيقية, إشارات ICA المستعادة, إشارات PCA المستعادة :srcset: /auto_examples/decomposition/images/sphx_glr_plot_ica_blind_source_separation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.513 seconds) .. _sphx_glr_download_auto_examples_decomposition_plot_ica_blind_source_separation.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/decomposition/plot_ica_blind_source_separation.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/decomposition/plot_ica_blind_source_separation.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ica_blind_source_separation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ica_blind_source_separation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ica_blind_source_separation.zip ` .. include:: plot_ica_blind_source_separation.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_