fix(clearning.ipynb): changement cross_val_score en score

This commit is contained in:
2026-04-01 16:24:48 +02:00
parent 5f33749956
commit f92f288a7b

View File

@@ -2,19 +2,10 @@
"cells": [
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 1,
"id": "faafb9a0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"outputs": [],
"source": [
"%matplotlib inline\n",
"%load_ext autoreload\n",
@@ -110,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 2,
"id": "8342340f",
"metadata": {},
"outputs": [],
@@ -135,7 +126,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 3,
"id": "9dfdc01f",
"metadata": {},
"outputs": [],
@@ -184,7 +175,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 4,
"id": "99de3ed7",
"metadata": {},
"outputs": [
@@ -217,7 +208,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 5,
"id": "09eca16d",
"metadata": {},
"outputs": [
@@ -255,7 +246,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 6,
"id": "b94a89f2",
"metadata": {},
"outputs": [
@@ -332,7 +323,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 7,
"id": "4f1c169f",
"metadata": {},
"outputs": [
@@ -369,7 +360,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 8,
"id": "91cedffb",
"metadata": {},
"outputs": [
@@ -466,7 +457,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 9,
"id": "4c21cd56",
"metadata": {},
"outputs": [
@@ -528,9 +519,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|AD|0.511089|\n",
"|Normalisation + AD|0.508518|\n",
"|Standardisation + AD|0.512649|\n"
"|AD|0.510519|\n",
"|Normalisation + AD|0.508927|\n",
"|Standardisation + AD|0.506827|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -543,7 +534,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best score= 0.512649496806262 depth= 5 method= Standardisation + AD\n"
"best score= 0.5105192880780061 depth= 5 method= AD\n"
]
}
],
@@ -614,6 +605,14 @@
"Refaites lexpérience avec un paramètre n_neigbors=5. Laugmentation du nombre de voisins considérés permet-elle de meilleurs résultats ? Si cette amélioration nest pas significative, nous conserverons n_neighbors = 4 pour la suite, par souci de simplicité."
]
},
{
"cell_type": "markdown",
"id": "88185c62",
"metadata": {},
"source": [
"Aucune amélioration signification par rapport au pré et post traitement"
]
},
{
"cell_type": "markdown",
"id": "72869cf6",
@@ -625,7 +624,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 10,
"id": "f72f499f",
"metadata": {},
"outputs": [
@@ -641,9 +640,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|KNN|0.485764|\n",
"|Normalisation + KNN|0.497729|\n",
"|Standardisation + KNN|0.489906|\n"
"|KNN|0.463459|\n",
"|Normalisation + KNN|0.465584|\n",
"|Standardisation + KNN|0.480575|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -664,9 +663,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|KNN|0.504888|\n",
"|Normalisation + KNN|0.500504|\n",
"|Standardisation + KNN|0.493475|\n"
"|KNN|0.492485|\n",
"|Normalisation + KNN|0.485298|\n",
"|Standardisation + KNN|0.495728|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -679,7 +678,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best score= 0.5048884037669835 neighbor= 5 method= KNN\n"
"best score= 0.49572822708745434 neighbor= 5 method= Standardisation + KNN\n"
]
}
],
@@ -707,7 +706,7 @@
" else make_pipeline(scaler(), KNeighborsRegressor(n_neighbors=n))\n",
" )\n",
" model.fit(X_train, y_train)\n",
" score: float = cross_val_score(model, X_train, y_train, cv=5).mean()\n",
" score: float = model.score(X_test, y_test)\n",
" knn_table.ajoutligne(f\"{name}\", score)\n",
"\n",
" if score > best_score_knn:\n",
@@ -749,7 +748,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 11,
"id": "9f764f3a",
"metadata": {},
"outputs": [
@@ -759,8 +758,8 @@
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|LR|0.452908|\n",
"|AD|0.512649|\n",
"|KNN|0.504888|\n"
"|AD|0.510519|\n",
"|KNN|0.495728|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -773,7 +772,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best_model= AD best_scaler= StandardScaler\n"
"best_model= AD best_scaler= DecisionTreeRegressor\n"
]
}
],
@@ -813,7 +812,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 12,
"id": "9084e87e",
"metadata": {},
"outputs": [
@@ -850,17 +849,17 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 13,
"id": "fdcdfb17",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.3938363073944231"
"0.39383630739442343"
]
},
"execution_count": 43,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -902,7 +901,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 14,
"id": "c4f6c27f",
"metadata": {},
"outputs": [
@@ -912,7 +911,7 @@
"<Axes: >"
]
},
"execution_count": 44,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
},
@@ -947,7 +946,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 15,
"id": "2e512052",
"metadata": {},
"outputs": [
@@ -1134,7 +1133,7 @@
"App_Haut-Médoc -0.070383"
]
},
"execution_count": 45,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -1155,7 +1154,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 16,
"id": "4010aa12",
"metadata": {},
"outputs": [
@@ -1165,7 +1164,7 @@
"0.4489472637581393"
]
},
"execution_count": 46,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -1213,7 +1212,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 17,
"id": "1510f763",
"metadata": {},
"outputs": [
@@ -1222,9 +1221,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|Random Forest|0.496806|\n",
"|Normalisation + RF|0.494283|\n",
"|Standardisation + RF|0.486890|\n"
"|Random Forest|0.492518|\n",
"|Normalisation + RF|0.491729|\n",
"|Standardisation + RF|0.483625|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"