{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Démo Iris: entraînement et prédiction\n",
"Ce notebook entraîne un modèle Iris et le sauvegarde dans `shared/models/iris_model.pkl` via le script Python."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'Python 3.13.3' requires the ipykernel package.\n",
"\u001b[1;31mCreate a Python Environment with the required packages.\n",
"\u001b[1;31mOr install 'ipykernel' using the command: 'c:/Users/brin.amonkonan/AppData/Local/Programs/Python/Python313/python.exe -m pip install ipykernel -U --user --force-reinstall'"
]
}
],
"source": [
"# Exécute le script d'entraînement (Iris)\n",
"import sys, subprocess\n",
"subprocess.run([sys.executable, '/work/app/train_iris.py'], check=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'Python 3.13.3' requires the ipykernel package.\n",
"\u001b[1;31mCreate a Python Environment with the required packages.\n",
"\u001b[1;31mOr install 'ipykernel' using the command: 'c:/Users/brin.amonkonan/AppData/Local/Programs/Python/Python313/python.exe -m pip install ipykernel -U --user --force-reinstall'"
]
}
],
"source": [
"# Vérifie que le modèle est sauvegardé et effectue une prédiction\n",
"from pathlib import Path\n",
"import joblib\n",
"import numpy as np\n",
"model_path = Path('/work/models/iris_model.pkl')\n",
"assert model_path.exists(), 'Le modèle n’a pas été sauvegardé.'\n",
"model = joblib.load(model_path)\n",
"X = np.array([5.1, 3.5, 1.4, 0.2]).reshape(1, -1)\n",
"pred = model.predict(X)\n",
"pred"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}