.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ensemble/plot_random_forest_regression_multioutput.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_ensemble_plot_random_forest_regression_multioutput.py: ============================================================ مقارنة الغابات العشوائية ومقدر المخرجات المتعددة التلوي ============================================================ مثال لمقارنة انحدار المخرجات المتعددة مع الغابة العشوائية والمقدر التلوي :ref:`multioutput.MultiOutputRegressor `. يوضح هذا المثال استخدام المقدر التلوي :ref:`multioutput.MultiOutputRegressor ` لإجراء انحدار متعدد المخرجات. يتم استخدام مُنحدِر غابة عشوائية، والذي يدعم انحدار المخرجات المتعددة أصلاً، بحيث يمكن مقارنة النتائج. لن يتنبأ مُنحدِر الغابة العشوائية إلا بالقيم ضمن نطاق الملاحظات أو الأقرب إلى الصفر لكل هدف. نتيجة لذلك، يكون التنبؤ متحيزًا نحو مركز الدائرة. باستخدام ميزة أساسية واحدة، يتعلم النموذج كلاً من إحداثيات x و y كمخرجات. .. GENERATED FROM PYTHON SOURCE LINES 23-99 .. image-sg:: /auto_examples/ensemble/images/sphx_glr_plot_random_forest_regression_multioutput_001.png :alt: مقارنة الغابات العشوائية ومقدر المخرجات المتعددة التلوي :srcset: /auto_examples/ensemble/images/sphx_glr_plot_random_forest_regression_multioutput_001.png :class: sphx-glr-single-img .. code-block:: Python # Authors: The scikit-learn developers # SPDX-License-Identifier: BSD-3-Clause import matplotlib.pyplot as plt import numpy as np from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split from sklearn.multioutput import MultiOutputRegressor # إنشاء مجموعة بيانات عشوائية rng = np.random.RandomState(1) X = np.sort(200 * rng.rand(600, 1) - 100, axis=0) y = np.array([np.pi * np.sin(X).ravel(), np.pi * np.cos(X).ravel()]).T y += 0.5 - rng.rand(*y.shape) X_train, X_test, y_train, y_test = train_test_split( X, y, train_size=400, test_size=200, random_state=4 ) max_depth = 30 regr_multirf = MultiOutputRegressor( RandomForestRegressor(n_estimators=100, max_depth=max_depth, random_state=0) ) regr_multirf.fit(X_train, y_train) regr_rf = RandomForestRegressor(n_estimators=100, max_depth=max_depth, random_state=2) regr_rf.fit(X_train, y_train) # التنبؤ ببيانات جديدة y_multirf = regr_multirf.predict(X_test) y_rf = regr_rf.predict(X_test) # رسم النتائج plt.figure() s = 50 a = 0.4 plt.scatter( y_test[:, 0], y_test[:, 1], edgecolor="k", c="navy", s=s, marker="s", alpha=a, label="البيانات", ) plt.scatter( y_multirf[:, 0], y_multirf[:, 1], edgecolor="k", c="cornflowerblue", s=s, alpha=a, label="نتيجة Multi RF=%.2f" % regr_multirf.score(X_test, y_test), ) plt.scatter( y_rf[:, 0], y_rf[:, 1], edgecolor="k", c="c", s=s, marker="^", alpha=a, label="نتيجة RF=%.2f" % regr_rf.score(X_test, y_test), ) plt.xlim([-6, 6]) plt.ylim([-6, 6]) plt.xlabel("الهدف 1") plt.ylabel("الهدف 2") plt.title("مقارنة الغابات العشوائية ومقدر المخرجات المتعددة التلوي") plt.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.595 seconds) .. _sphx_glr_download_auto_examples_ensemble_plot_random_forest_regression_multioutput.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/ensemble/plot_random_forest_regression_multioutput.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/ensemble/plot_random_forest_regression_multioutput.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_random_forest_regression_multioutput.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_random_forest_regression_multioutput.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_random_forest_regression_multioutput.zip ` .. include:: plot_random_forest_regression_multioutput.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_