Задание завершено

This commit is contained in:
Алексей Пастухов 2025-05-15 23:33:50 +03:00
parent 0b23a41bf2
commit 83335430f2
2 changed files with 549 additions and 0 deletions

View File

@ -0,0 +1,82 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "ece59960-3ec4-4347-a445-fe84dd84a773",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" 0 1.00 1.00 1.00 14\n",
" 1 1.00 0.62 0.76 13\n",
" 2 0.38 1.00 0.55 3\n",
"\n",
" accuracy 0.83 30\n",
" macro avg 0.79 0.87 0.77 30\n",
"weighted avg 0.94 0.83 0.85 30\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\leafy\\3labPython\\.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=2500)\n",
"clf.fit(X_train, y_train)\n",
"\n",
"# Отчёт о точности\n",
"print(classification_report(y_test, clf.predict(X_test)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e5b2022-40e1-42de-816a-dd04ace07431",
"metadata": {},
"outputs": [],
"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
}

467
week4_scikit_learn.ipynb Normal file

File diff suppressed because one or more lines are too long