mirror of
https://github.com/guezoloic/millesima-ai-engine.git
synced 2026-04-02 13:31:34 +00:00
fix(learning.ipynb): correction cross_val_score avec uniquement X_test et y_test
This commit is contained in:
@@ -2,10 +2,19 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 12,
|
||||||
"id": "faafb9a0",
|
"id": "faafb9a0",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"The autoreload extension is already loaded. To reload it, use:\n",
|
||||||
|
" %reload_ext autoreload\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"%matplotlib inline\n",
|
"%matplotlib inline\n",
|
||||||
"%load_ext autoreload\n",
|
"%load_ext autoreload\n",
|
||||||
@@ -101,7 +110,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 13,
|
||||||
"id": "8342340f",
|
"id": "8342340f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -126,7 +135,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 14,
|
||||||
"id": "9dfdc01f",
|
"id": "9dfdc01f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -175,7 +184,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 15,
|
||||||
"id": "99de3ed7",
|
"id": "99de3ed7",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -208,7 +217,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 16,
|
||||||
"id": "09eca16d",
|
"id": "09eca16d",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -246,7 +255,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 6,
|
"execution_count": 17,
|
||||||
"id": "b94a89f2",
|
"id": "b94a89f2",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -323,7 +332,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 18,
|
||||||
"id": "4f1c169f",
|
"id": "4f1c169f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -360,7 +369,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": 19,
|
||||||
"id": "91cedffb",
|
"id": "91cedffb",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -457,7 +466,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 20,
|
||||||
"id": "4c21cd56",
|
"id": "4c21cd56",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -473,9 +482,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|AD|0.393010|\n",
|
"|AD|0.386319|\n",
|
||||||
"|Normalisation + AD|0.393010|\n",
|
"|Normalisation + AD|0.386319|\n",
|
||||||
"|Standardisation + AD|0.393034|\n"
|
"|Standardisation + AD|0.386319|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -496,9 +505,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|AD|0.403744|\n",
|
"|AD|0.382689|\n",
|
||||||
"|Normalisation + AD|0.403744|\n",
|
"|Normalisation + AD|0.382695|\n",
|
||||||
"|Standardisation + AD|0.403761|\n"
|
"|Standardisation + AD|0.382691|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -519,9 +528,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|AD|0.400791|\n",
|
"|AD|0.371764|\n",
|
||||||
"|Normalisation + AD|0.400791|\n",
|
"|Normalisation + AD|0.374744|\n",
|
||||||
"|Standardisation + AD|0.400821|\n"
|
"|Standardisation + AD|0.371729|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -534,7 +543,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"best score= 0.40376125774243815 depth= 4 method= Standardisation + AD\n"
|
"best score= 0.3863187373819251 depth= 3 method= AD\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -562,7 +571,7 @@
|
|||||||
" else make_pipeline(scaler(), DecisionTreeRegressor(max_depth=depth))\n",
|
" else make_pipeline(scaler(), DecisionTreeRegressor(max_depth=depth))\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
" model.fit(X_train, y_train)\n",
|
" model.fit(X_train, y_train)\n",
|
||||||
" score: float = cross_val_score(model, X, y_log, cv=5).mean()\n",
|
" score: float = cross_val_score(model, X_test, y_test, cv=5).mean()\n",
|
||||||
" ad_table.ajoutligne(f\"{name}\", score)\n",
|
" ad_table.ajoutligne(f\"{name}\", score)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if score > best_score_ad:\n",
|
" if score > best_score_ad:\n",
|
||||||
@@ -616,7 +625,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 10,
|
"execution_count": 21,
|
||||||
"id": "f72f499f",
|
"id": "f72f499f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -632,9 +641,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|KNN|0.371305|\n",
|
"|KNN|0.370389|\n",
|
||||||
"|Normalisation + KNN|0.392151|\n",
|
"|Normalisation + KNN|0.341947|\n",
|
||||||
"|Standardisation + KNN|0.392397|\n"
|
"|Standardisation + KNN|0.369662|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -655,9 +664,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|KNN|0.391092|\n",
|
"|KNN|0.390801|\n",
|
||||||
"|Normalisation + KNN|0.412238|\n",
|
"|Normalisation + KNN|0.349482|\n",
|
||||||
"|Standardisation + KNN|0.402197|\n"
|
"|Standardisation + KNN|0.381631|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -670,7 +679,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"best score= 0.4122380532367001 neighbor= 5 method= Normalisation + KNN\n"
|
"best score= 0.39080066451618123 neighbor= 5 method= KNN\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -698,7 +707,7 @@
|
|||||||
" else make_pipeline(scaler(), KNeighborsRegressor(n_neighbors=n))\n",
|
" else make_pipeline(scaler(), KNeighborsRegressor(n_neighbors=n))\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
" model.fit(X_train, y_train)\n",
|
" model.fit(X_train, y_train)\n",
|
||||||
" score: float = cross_val_score(model, X, y_log, cv=5).mean()\n",
|
" score: float = cross_val_score(model, X_test, y_test, cv=5).mean()\n",
|
||||||
" knn_table.ajoutligne(f\"{name}\", score)\n",
|
" knn_table.ajoutligne(f\"{name}\", score)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if score > best_score_ad:\n",
|
" if score > best_score_ad:\n",
|
||||||
@@ -740,7 +749,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": 22,
|
||||||
"id": "9f764f3a",
|
"id": "9f764f3a",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -750,8 +759,8 @@
|
|||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|LR|0.452908|\n",
|
"|LR|0.452908|\n",
|
||||||
"|AD|0.403761|\n",
|
"|AD|0.386319|\n",
|
||||||
"|KNN|0.412238|\n"
|
"|KNN|0.390801|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -804,7 +813,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 12,
|
"execution_count": 23,
|
||||||
"id": "9084e87e",
|
"id": "9084e87e",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -841,7 +850,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 13,
|
"execution_count": 24,
|
||||||
"id": "fdcdfb17",
|
"id": "fdcdfb17",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -851,7 +860,7 @@
|
|||||||
"0.24194691318111572"
|
"0.24194691318111572"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 13,
|
"execution_count": 24,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -893,7 +902,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 14,
|
"execution_count": 25,
|
||||||
"id": "c4f6c27f",
|
"id": "c4f6c27f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -903,7 +912,7 @@
|
|||||||
"<Axes: >"
|
"<Axes: >"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 14,
|
"execution_count": 25,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
},
|
},
|
||||||
@@ -938,7 +947,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 15,
|
"execution_count": 26,
|
||||||
"id": "2e512052",
|
"id": "2e512052",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -1125,7 +1134,7 @@
|
|||||||
"App_Haut-Médoc -0.070383"
|
"App_Haut-Médoc -0.070383"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 15,
|
"execution_count": 26,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -1146,7 +1155,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 27,
|
||||||
"id": "4010aa12",
|
"id": "4010aa12",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -1156,7 +1165,7 @@
|
|||||||
"0.24551258031003886"
|
"0.24551258031003886"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 16,
|
"execution_count": 27,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -1204,7 +1213,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 17,
|
"execution_count": 28,
|
||||||
"id": "1510f763",
|
"id": "1510f763",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -1213,9 +1222,9 @@
|
|||||||
"text/markdown": [
|
"text/markdown": [
|
||||||
"| Méthode | R² |\n",
|
"| Méthode | R² |\n",
|
||||||
"| :---: | :---: |\n",
|
"| :---: | :---: |\n",
|
||||||
"|Random Forest|0.493344|\n",
|
"|Random Forest|0.492498|\n",
|
||||||
"|Normalisation + RF|0.493113|\n",
|
"|Normalisation + RF|0.492721|\n",
|
||||||
"|Standardisation + RF|0.493782|\n"
|
"|Standardisation + RF|0.500235|\n"
|
||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Markdown object>"
|
"<IPython.core.display.Markdown object>"
|
||||||
@@ -1279,7 +1288,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.20"
|
"version": "3.14.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user