.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ensemble/plot_voting_regressor.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_voting_regressor.py: ================================================= رسم تنبؤات الانحدار الفردية والتصويتية ================================================= .. currentmodule:: sklearn مُنحدِر التصويت هو مقدر تلوي جماعي يقوم بملاءمة العديد من المُنحدرات الأساسية، كل منها على مجموعة البيانات بأكملها. ثم يقوم بمتوسط ​​التنبؤات الفردية لتشكيل تنبؤ نهائي. سنستخدم ثلاثة مُنحدرات مختلفة للتنبؤ بالبيانات: :class:`~ensemble.GradientBoostingRegressor` و :class:`~ensemble.RandomForestRegressor` و :class:`~linear_model.LinearRegression`). ثم سيتم استخدام المُنحدرات الثلاثة المذكورة أعلاه لـ :class:`~ensemble.VotingRegressor`. أخيرًا، سنرسم التنبؤات التي تم إجراؤها بواسطة جميع النماذج للمقارنة. سنعمل مع مجموعة بيانات مرض السكري التي تتكون من 10 ميزات تم جمعها من مجموعة من مرضى السكري. الهدف هو قياس كمي لتطور المرض بعد عام واحد من خط الأساس. .. GENERATED FROM PYTHON SOURCE LINES 25-39 .. code-block:: Python # Authors: The scikit-learn developers # SPDX-License-Identifier: BSD-3-Clause import matplotlib.pyplot as plt from sklearn.datasets import load_diabetes from sklearn.ensemble import ( GradientBoostingRegressor, RandomForestRegressor, VotingRegressor, ) from sklearn.linear_model import LinearRegression .. GENERATED FROM PYTHON SOURCE LINES 40-46 تدريب المصنفات -------------------------------- أولاً، سنقوم بتحميل مجموعة بيانات مرض السكري وبدء مُنحدِر التعزيز المتدرج، ومُنحدِر غابة عشوائية، وانحدار خطي. بعد ذلك، سنستخدم المُنحدرات الثلاثة لبناء مُنحدِر التصويت: .. GENERATED FROM PYTHON SOURCE LINES 46-61 .. code-block:: Python X, y = load_diabetes(return_X_y=True) # تدريب المصنفات reg1 = GradientBoostingRegressor(random_state=1) reg2 = RandomForestRegressor(random_state=1) reg3 = LinearRegression() reg1.fit(X, y) reg2.fit(X, y) reg3.fit(X, y) ereg = VotingRegressor([("gb", reg1), ("rf", reg2), ("lr", reg3)]) ereg.fit(X, y) .. raw:: html
VotingRegressor(estimators=[('gb', GradientBoostingRegressor(random_state=1)),
                                ('rf', RandomForestRegressor(random_state=1)),
                                ('lr', LinearRegression())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.


.. GENERATED FROM PYTHON SOURCE LINES 62-66 إجراء التنبؤات -------------------------------- الآن سنستخدم كل مُنحدِر لإجراء التنبؤات العشرين الأولى. .. GENERATED FROM PYTHON SOURCE LINES 66-74 .. code-block:: Python xt = X[:20] pred1 = reg1.predict(xt) pred2 = reg2.predict(xt) pred3 = reg3.predict(xt) pred4 = ereg.predict(xt) .. GENERATED FROM PYTHON SOURCE LINES 75-80 رسم النتائج -------------------------------- أخيرًا، سنقوم بتصور التنبؤات العشرين. تُظهر النجوم الحمراء متوسط ​​التنبؤ الذي تم إجراؤه بواسطة :class:`~ensemble.VotingRegressor`. .. GENERATED FROM PYTHON SOURCE LINES 80-97 .. code-block:: Python plt.figure() plt.plot(pred1, "gd", label="GradientBoostingRegressor") plt.plot(pred2, "b^", label="RandomForestRegressor") plt.plot(pred3, "ys", label="LinearRegression") plt.plot(pred4, "r*", ms=10, label="VotingRegressor") plt.tick_params(axis="x", which="both", bottom=False, top=False, labelbottom=False) plt.ylabel("متوقع") plt.xlabel("عينات التدريب") plt.legend(loc="best") plt.title("تنبؤات المُنحدِر ومتوسطها") plt.show() .. image-sg:: /auto_examples/ensemble/images/sphx_glr_plot_voting_regressor_001.png :alt: تنبؤات المُنحدِر ومتوسطها :srcset: /auto_examples/ensemble/images/sphx_glr_plot_voting_regressor_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.001 seconds) .. _sphx_glr_download_auto_examples_ensemble_plot_voting_regressor.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_voting_regressor.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_voting_regressor.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_voting_regressor.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_voting_regressor.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_voting_regressor.zip ` .. include:: plot_voting_regressor.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_