Работа 4 сделана
This commit is contained in:
parent
c54607d20c
commit
f3a9a1f7cb
550
.ipynb_checkpoints/Support_Vector_Machines-checkpoint.ipynb
Normal file
550
.ipynb_checkpoints/Support_Vector_Machines-checkpoint.ipynb
Normal file
File diff suppressed because one or more lines are too long
180
.ipynb_checkpoints/week4_scikit_learn-checkpoint.ipynb
Normal file
180
.ipynb_checkpoints/week4_scikit_learn-checkpoint.ipynb
Normal file
@ -0,0 +1,180 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2703a83e-6b0b-4be3-9439-bf19482185ec",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Выполнение кода из примера"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "385a0e7d-27e3-4f28-8f00-5dc14227f034",
|
||||
"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 1.00 1.00 7\n",
|
||||
" 2 1.00 1.00 1.00 9\n",
|
||||
"\n",
|
||||
" accuracy 1.00 30\n",
|
||||
" macro avg 1.00 1.00 1.00 30\n",
|
||||
"weighted avg 1.00 1.00 1.00 30\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\1\\Desktop\\praktika04\\venv\\Lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:785: 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": "code",
|
||||
"execution_count": 7,
|
||||
"id": "57225ea2-43d7-4399-834b-b2f121dd9a0c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" precision recall f1-score support\n",
|
||||
"\n",
|
||||
" 0 1.00 0.91 0.95 11\n",
|
||||
" 1 0.20 0.12 0.15 8\n",
|
||||
" 2 0.53 0.73 0.62 11\n",
|
||||
"\n",
|
||||
" accuracy 0.63 30\n",
|
||||
" macro avg 0.58 0.59 0.57 30\n",
|
||||
"weighted avg 0.62 0.63 0.62 30\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\1\\Desktop\\praktika04\\venv\\Lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) 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=100)\n",
|
||||
"clf.fit(X_train, y_train)\n",
|
||||
"\n",
|
||||
"# Отчёт о точности\n",
|
||||
"print(classification_report(y_test, clf.predict(X_test)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "5b9778ff-7d14-4d68-8119-2ebfdb468bf1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" precision recall f1-score support\n",
|
||||
"\n",
|
||||
" 0 1.00 1.00 1.00 9\n",
|
||||
" 1 1.00 0.93 0.96 14\n",
|
||||
" 2 0.88 1.00 0.93 7\n",
|
||||
"\n",
|
||||
" accuracy 0.97 30\n",
|
||||
" macro avg 0.96 0.98 0.97 30\n",
|
||||
"weighted avg 0.97 0.97 0.97 30\n",
|
||||
"\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": "8c642bb6-7583-466c-8864-2ee80d5accc7",
|
||||
"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.14.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
550
Support_Vector_Machines.ipynb
Normal file
550
Support_Vector_Machines.ipynb
Normal file
File diff suppressed because one or more lines are too long
180
week4_scikit_learn.ipynb
Normal file
180
week4_scikit_learn.ipynb
Normal file
@ -0,0 +1,180 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2703a83e-6b0b-4be3-9439-bf19482185ec",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Выполнение кода из примера"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "385a0e7d-27e3-4f28-8f00-5dc14227f034",
|
||||
"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 1.00 1.00 7\n",
|
||||
" 2 1.00 1.00 1.00 9\n",
|
||||
"\n",
|
||||
" accuracy 1.00 30\n",
|
||||
" macro avg 1.00 1.00 1.00 30\n",
|
||||
"weighted avg 1.00 1.00 1.00 30\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\1\\Desktop\\praktika04\\venv\\Lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:785: 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": "code",
|
||||
"execution_count": 7,
|
||||
"id": "57225ea2-43d7-4399-834b-b2f121dd9a0c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" precision recall f1-score support\n",
|
||||
"\n",
|
||||
" 0 1.00 0.91 0.95 11\n",
|
||||
" 1 0.20 0.12 0.15 8\n",
|
||||
" 2 0.53 0.73 0.62 11\n",
|
||||
"\n",
|
||||
" accuracy 0.63 30\n",
|
||||
" macro avg 0.58 0.59 0.57 30\n",
|
||||
"weighted avg 0.62 0.63 0.62 30\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\1\\Desktop\\praktika04\\venv\\Lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) 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=100)\n",
|
||||
"clf.fit(X_train, y_train)\n",
|
||||
"\n",
|
||||
"# Отчёт о точности\n",
|
||||
"print(classification_report(y_test, clf.predict(X_test)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "5b9778ff-7d14-4d68-8119-2ebfdb468bf1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" precision recall f1-score support\n",
|
||||
"\n",
|
||||
" 0 1.00 1.00 1.00 9\n",
|
||||
" 1 1.00 0.93 0.96 14\n",
|
||||
" 2 0.88 1.00 0.93 7\n",
|
||||
"\n",
|
||||
" accuracy 0.97 30\n",
|
||||
" macro avg 0.96 0.98 0.97 30\n",
|
||||
"weighted avg 0.97 0.97 0.97 30\n",
|
||||
"\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": "8c642bb6-7583-466c-8864-2ee80d5accc7",
|
||||
"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.14.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user