fix(learning.ipynb): cross_val_score erreur ajout X_train

This commit is contained in:
2026-04-01 15:48:01 +02:00
parent 8074c95720
commit e89bd795f6

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 31,
"id": "faafb9a0",
"metadata": {},
"outputs": [
@@ -110,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 32,
"id": "8342340f",
"metadata": {},
"outputs": [],
@@ -135,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 33,
"id": "9dfdc01f",
"metadata": {},
"outputs": [],
@@ -184,7 +184,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 34,
"id": "99de3ed7",
"metadata": {},
"outputs": [
@@ -217,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 35,
"id": "09eca16d",
"metadata": {},
"outputs": [
@@ -255,7 +255,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 36,
"id": "b94a89f2",
"metadata": {},
"outputs": [
@@ -332,7 +332,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 37,
"id": "4f1c169f",
"metadata": {},
"outputs": [
@@ -369,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 38,
"id": "91cedffb",
"metadata": {},
"outputs": [
@@ -466,7 +466,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 39,
"id": "4c21cd56",
"metadata": {},
"outputs": [
@@ -482,9 +482,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|AD|0.386319|\n",
"|Normalisation + AD|0.386319|\n",
"|Standardisation + AD|0.386319|\n"
"|AD|0.483688|\n",
"|Normalisation + AD|0.483688|\n",
"|Standardisation + AD|0.483719|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -505,9 +505,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|AD|0.382689|\n",
"|Normalisation + AD|0.382695|\n",
"|Standardisation + AD|0.382691|\n"
"|AD|0.501187|\n",
"|Normalisation + AD|0.501187|\n",
"|Standardisation + AD|0.501185|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -528,9 +528,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|AD|0.371764|\n",
"|Normalisation + AD|0.374744|\n",
"|Standardisation + AD|0.371729|\n"
"|AD|0.511089|\n",
"|Normalisation + AD|0.508518|\n",
"|Standardisation + AD|0.512649|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -543,7 +543,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best score= 0.3863187373819251 depth= 3 method= AD\n"
"best score= 0.512649496806262 depth= 5 method= Standardisation + AD\n"
]
}
],
@@ -571,7 +571,7 @@
" else make_pipeline(scaler(), DecisionTreeRegressor(max_depth=depth))\n",
" )\n",
" model.fit(X_train, y_train)\n",
" score: float = cross_val_score(model, X_test, y_test, cv=5).mean()\n",
" score: float = cross_val_score(model, X_train, y_train, cv=5).mean()\n",
" ad_table.ajoutligne(f\"{name}\", score)\n",
"\n",
" if score > best_score_ad:\n",
@@ -625,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 40,
"id": "f72f499f",
"metadata": {},
"outputs": [
@@ -641,9 +641,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|KNN|0.370389|\n",
"|Normalisation + KNN|0.341947|\n",
"|Standardisation + KNN|0.369662|\n"
"|KNN|0.485764|\n",
"|Normalisation + KNN|0.497729|\n",
"|Standardisation + KNN|0.489906|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -664,9 +664,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|KNN|0.390801|\n",
"|Normalisation + KNN|0.349482|\n",
"|Standardisation + KNN|0.381631|\n"
"|KNN|0.504888|\n",
"|Normalisation + KNN|0.500504|\n",
"|Standardisation + KNN|0.493475|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -679,7 +679,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best score= 0.39080066451618123 neighbor= 5 method= KNN\n"
"best score= 0.5048884037669835 neighbor= 5 method= KNN\n"
]
}
],
@@ -707,10 +707,10 @@
" else make_pipeline(scaler(), KNeighborsRegressor(n_neighbors=n))\n",
" )\n",
" model.fit(X_train, y_train)\n",
" score: float = cross_val_score(model, X_test, y_test, cv=5).mean()\n",
" score: float = cross_val_score(model, X_train, y_train, cv=5).mean()\n",
" knn_table.ajoutligne(f\"{name}\", score)\n",
"\n",
" if score > best_score_ad:\n",
" if score > best_score_knn:\n",
" best_score_knn = score\n",
" best_neighbor = n\n",
" best_scaler_name = name\n",
@@ -749,7 +749,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 41,
"id": "9f764f3a",
"metadata": {},
"outputs": [
@@ -759,8 +759,8 @@
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|LR|0.452908|\n",
"|AD|0.386319|\n",
"|KNN|0.390801|\n"
"|AD|0.512649|\n",
"|KNN|0.504888|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@@ -773,7 +773,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"best_model= LR best_scaler= MinMaxScaler\n"
"best_model= AD best_scaler= StandardScaler\n"
]
}
],
@@ -813,7 +813,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 42,
"id": "9084e87e",
"metadata": {},
"outputs": [
@@ -850,17 +850,17 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 43,
"id": "fdcdfb17",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.24194691318111572"
"0.3938363073944231"
]
},
"execution_count": 24,
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
@@ -902,7 +902,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 44,
"id": "c4f6c27f",
"metadata": {},
"outputs": [
@@ -912,7 +912,7 @@
"<Axes: >"
]
},
"execution_count": 25,
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
},
@@ -947,7 +947,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 45,
"id": "2e512052",
"metadata": {},
"outputs": [
@@ -1134,7 +1134,7 @@
"App_Haut-Médoc -0.070383"
]
},
"execution_count": 26,
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
@@ -1155,17 +1155,17 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 46,
"id": "4010aa12",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.24551258031003886"
"0.4489472637581393"
]
},
"execution_count": 27,
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
@@ -1213,7 +1213,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 47,
"id": "1510f763",
"metadata": {},
"outputs": [
@@ -1222,9 +1222,9 @@
"text/markdown": [
"| Méthode | R² |\n",
"| :---: | :---: |\n",
"|Random Forest|0.492498|\n",
"|Normalisation + RF|0.492721|\n",
"|Standardisation + RF|0.500235|\n"
"|Random Forest|0.496806|\n",
"|Normalisation + RF|0.494283|\n",
"|Standardisation + RF|0.486890|\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"