mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-01-14 18:59:59 +01:00
- Updated import order in Point_Fixe.ipynb for consistency. - Changed lambda functions to regular function definitions for clarity in Point_Fixe.ipynb. - Added numpy import in TP1_EDO_EulerExp.ipynb, TP2_Lokta_Volterra.ipynb, and TP3_Convergence.ipynb for better readability. - Modified for loops in TP1_EDO_EulerExp.ipynb and TP2_Lokta_Volterra.ipynb to include strict=False for compatibility with future Python versions.
104 lines
2.6 KiB
Plaintext
104 lines
2.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c897654e0a140cbd",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Automatic Differentiation\n",
|
|
"\n",
|
|
"### Neural Network\n",
|
|
"\n",
|
|
"Loss function: softmax layer in $\\mathbb{R}^3$\n",
|
|
"\n",
|
|
"Architecture: FC/ReLU 4-5-7-3"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 33,
|
|
"id": "70a4eb1d928b10d0",
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2025-03-24T15:16:27.015669Z",
|
|
"start_time": "2025-03-24T15:16:23.856887Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Mean Accuracy: 94%\n",
|
|
"STD Accuracy: 3%\n",
|
|
"Max accuracy: 100%\n",
|
|
"Min accuracy: 88%\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import numpy as np\n",
|
|
"from sklearn.datasets import make_classification\n",
|
|
"from sklearn.metrics import accuracy_score\n",
|
|
"from sklearn.model_selection import train_test_split\n",
|
|
"from sklearn.neural_network import MLPClassifier\n",
|
|
"\n",
|
|
"accuracies = []\n",
|
|
"\n",
|
|
"for _ in range(10):\n",
|
|
" X, y = make_classification(\n",
|
|
" n_samples=1000, n_features=4, n_classes=3, n_clusters_per_class=1\n",
|
|
" )\n",
|
|
"\n",
|
|
" X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n",
|
|
" model = MLPClassifier(\n",
|
|
" hidden_layer_sizes=(5, 7), activation=\"relu\", max_iter=10000, solver=\"adam\"\n",
|
|
" )\n",
|
|
" model.fit(X_train, y_train)\n",
|
|
"\n",
|
|
" y_pred = model.predict(X_test)\n",
|
|
" accuracies.append(accuracy_score(y_test, y_pred))\n",
|
|
"\n",
|
|
"print(f\"Mean Accuracy: {np.mean(accuracies) * 100:.0f}%\")\n",
|
|
"print(f\"STD Accuracy: {np.std(accuracies) * 100:.0f}%\")\n",
|
|
"print(f\"Max accuracy: {np.max(accuracies) * 100:.0f}%\")\n",
|
|
"print(f\"Min accuracy: {np.min(accuracies) * 100:.0f}%\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "96b6d46883ed5570",
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2025-03-24T14:37:53.507776Z",
|
|
"start_time": "2025-03-24T14:37:53.505376Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 2
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython2",
|
|
"version": "2.7.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|