{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# \ud83d\udcdd Exercise M7.02\n", "\n", "We presented different classification metrics in the previous notebook.\n", "However, we did not use it with a cross-validation. This exercise aims at\n", "practicing and implementing cross-validation.\n", "\n", "Here we use the blood transfusion dataset." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "blood_transfusion = pd.read_csv(\"../datasets/blood_transfusion.csv\")\n", "data = blood_transfusion.drop(columns=\"Class\")\n", "target = blood_transfusion[\"Class\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
Note
\n", "If you want a deeper overview regarding this dataset, you can refer to the\n", "Appendix - Datasets description section at the end of this MOOC.
\n", "Tip
\n", "We use a try/except block to catch possible ValueErrors and print them\n", "if they occur. By setting error_score=\"raise\", we ensure that the exception\n", "is raised immediately when an error is encountered. Without this setting, the\n", "code would show a warning for each cross-validation split before raising the\n", "exception. You can try using the default error_score to better understand\n", "what this means.
\n", "