{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "784f3b45-efc8-49dc-b677-cc994b66d7d4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " precision recall f1-score support\n", "\n", " 0 1.00 1.00 1.00 8\n", " 1 0.73 1.00 0.84 8\n", " 2 1.00 0.79 0.88 14\n", "\n", " accuracy 0.90 30\n", " macro avg 0.91 0.93 0.91 30\n", "weighted avg 0.93 0.90 0.90 30\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "D:\\Files\\4week\\venv\\Lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:691: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.\n", " warnings.warn(\n" ] } ], "source": [ "from sklearn.datasets import load_iris\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.neural_network import MLPClassifier\n", "from sklearn.metrics import classification_report\n", "\n", "# Загрузка и разбиение данных\n", "X, y = load_iris(return_X_y=True)\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n", "\n", "# Модель MLP — многослойный перцептрон\n", "clf = MLPClassifier(hidden_layer_sizes=(10,), activation='relu', max_iter=500)\n", "clf.fit(X_train, y_train)\n", "\n", "# Отчёт о точности\n", "print(classification_report(y_test, clf.predict(X_test)))" ] }, { "cell_type": "markdown", "id": "945fb3ca-7876-49ef-9418-0486618ac07b", "metadata": {}, "source": [ "Выполнил код, данный в примере" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.3" } }, "nbformat": 4, "nbformat_minor": 5 }