Refactor code in numerical methods notebooks

- 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.
This commit is contained in:
2025-09-01 16:14:53 +02:00
parent dfee405ea0
commit 8cf328e18a
31 changed files with 177 additions and 156 deletions

View File

@@ -48,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-26T10:34:01.222808Z",
@@ -433,9 +433,9 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd # dataframes are in pandas\n",
"import matplotlib.pyplot as plt\n",
"\n",
"hitters = pd.read_csv(\"data/Hitters.csv\", index_col=\"Name\")\n",
"\n",
@@ -896,11 +896,11 @@
"source": [
"# Hint for Question (4) :\n",
"ex = pd.DataFrame(\n",
" dict(\n",
" nom=[\"Alice\", \"Nicolas\", \"Jean\"],\n",
" age=[19, np.NaN, np.NaN],\n",
" exam=[15, 14, np.NaN],\n",
" )\n",
" {\n",
" \"nom\": [\"Alice\", \"Nicolas\", \"Jean\"],\n",
" \"age\": [19, np.NaN, np.NaN],\n",
" \"exam\": [15, 14, np.NaN],\n",
" }\n",
")\n",
"\n",
"print(\"data : \\n\", ex)\n",
@@ -2545,7 +2545,7 @@
"\n",
"MSEs = []\n",
"for name, estimator in zip(\n",
" [\"LassoCV\", \"LassoBIC\", \"RidgeCV\", \"OLS\"], [lassoCV, lassoBIC, ridgeCV, linReg]\n",
" [\"LassoCV\", \"LassoBIC\", \"RidgeCV\", \"OLS\"], [lassoCV, lassoBIC, ridgeCV, linReg], strict=False\n",
"):\n",
" y_pred = estimator.predict(Xtest)\n",
" MSE = mean_squared_error(Ytest, y_pred)\n",