{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "import numpy as np\n",
        "from sklearn.model_selection import train_test_split, GridSearchCV\n",
        "from sklearn.preprocessing import StandardScaler, LabelEncoder\n",
        "from sklearn.linear_model import LogisticRegression\n",
        "from sklearn.tree import DecisionTreeClassifier\n",
        "from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier\n",
        "from sklearn.svm import SVC\n",
        "from sklearn.naive_bayes import GaussianNB\n",
        "from sklearn.neighbors import KNeighborsClassifier\n",
        "from sklearn.metrics import accuracy_score, classification_report\n",
        "from sklearn.feature_selection import SelectKBest, f_classif\n",
        "from sklearn.ensemble import ExtraTreesClassifier\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns"
      ],
      "metadata": {
        "id": "kvKfKqiUQcpl"
      },
      "execution_count": 14,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# 2. Upload and Read Data\n",
        "from google.colab import files\n",
        "uploaded = files.upload()\n",
        "\n",
        "# Assume the uploaded file is 'kidney_disease (1).csv'\n",
        "df = pd.read_csv('kidney_disease (1).csv')\n",
        "\n",
        "# Display dataset information\n",
        "print(\"Dataset Dimensions:\", df.shape)\n",
        "print(\"\\nDataset Preview:\")\n",
        "display(df.head())"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 342
        },
        "id": "OPJK5IXCQgnh",
        "outputId": "2e1b467f-48c8-43aa-9bf4-e1e08de8257e"
      },
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<IPython.core.display.HTML object>"
            ],
            "text/html": [
              "\n",
              "     <input type=\"file\" id=\"files-98e08e86-b13d-4641-9e42-8b9de6bcfc9e\" name=\"files[]\" multiple disabled\n",
              "        style=\"border:none\" />\n",
              "     <output id=\"result-98e08e86-b13d-4641-9e42-8b9de6bcfc9e\">\n",
              "      Upload widget is only available when the cell has been executed in the\n",
              "      current browser session. Please rerun this cell to enable.\n",
              "      </output>\n",
              "      <script>// Copyright 2017 Google LLC\n",
              "//\n",
              "// Licensed under the Apache License, Version 2.0 (the \"License\");\n",
              "// you may not use this file except in compliance with the License.\n",
              "// You may obtain a copy of the License at\n",
              "//\n",
              "//      http://www.apache.org/licenses/LICENSE-2.0\n",
              "//\n",
              "// Unless required by applicable law or agreed to in writing, software\n",
              "// distributed under the License is distributed on an \"AS IS\" BASIS,\n",
              "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
              "// See the License for the specific language governing permissions and\n",
              "// limitations under the License.\n",
              "\n",
              "/**\n",
              " * @fileoverview Helpers for google.colab Python module.\n",
              " */\n",
              "(function(scope) {\n",
              "function span(text, styleAttributes = {}) {\n",
              "  const element = document.createElement('span');\n",
              "  element.textContent = text;\n",
              "  for (const key of Object.keys(styleAttributes)) {\n",
              "    element.style[key] = styleAttributes[key];\n",
              "  }\n",
              "  return element;\n",
              "}\n",
              "\n",
              "// Max number of bytes which will be uploaded at a time.\n",
              "const MAX_PAYLOAD_SIZE = 100 * 1024;\n",
              "\n",
              "function _uploadFiles(inputId, outputId) {\n",
              "  const steps = uploadFilesStep(inputId, outputId);\n",
              "  const outputElement = document.getElementById(outputId);\n",
              "  // Cache steps on the outputElement to make it available for the next call\n",
              "  // to uploadFilesContinue from Python.\n",
              "  outputElement.steps = steps;\n",
              "\n",
              "  return _uploadFilesContinue(outputId);\n",
              "}\n",
              "\n",
              "// This is roughly an async generator (not supported in the browser yet),\n",
              "// where there are multiple asynchronous steps and the Python side is going\n",
              "// to poll for completion of each step.\n",
              "// This uses a Promise to block the python side on completion of each step,\n",
              "// then passes the result of the previous step as the input to the next step.\n",
              "function _uploadFilesContinue(outputId) {\n",
              "  const outputElement = document.getElementById(outputId);\n",
              "  const steps = outputElement.steps;\n",
              "\n",
              "  const next = steps.next(outputElement.lastPromiseValue);\n",
              "  return Promise.resolve(next.value.promise).then((value) => {\n",
              "    // Cache the last promise value to make it available to the next\n",
              "    // step of the generator.\n",
              "    outputElement.lastPromiseValue = value;\n",
              "    return next.value.response;\n",
              "  });\n",
              "}\n",
              "\n",
              "/**\n",
              " * Generator function which is called between each async step of the upload\n",
              " * process.\n",
              " * @param {string} inputId Element ID of the input file picker element.\n",
              " * @param {string} outputId Element ID of the output display.\n",
              " * @return {!Iterable<!Object>} Iterable of next steps.\n",
              " */\n",
              "function* uploadFilesStep(inputId, outputId) {\n",
              "  const inputElement = document.getElementById(inputId);\n",
              "  inputElement.disabled = false;\n",
              "\n",
              "  const outputElement = document.getElementById(outputId);\n",
              "  outputElement.innerHTML = '';\n",
              "\n",
              "  const pickedPromise = new Promise((resolve) => {\n",
              "    inputElement.addEventListener('change', (e) => {\n",
              "      resolve(e.target.files);\n",
              "    });\n",
              "  });\n",
              "\n",
              "  const cancel = document.createElement('button');\n",
              "  inputElement.parentElement.appendChild(cancel);\n",
              "  cancel.textContent = 'Cancel upload';\n",
              "  const cancelPromise = new Promise((resolve) => {\n",
              "    cancel.onclick = () => {\n",
              "      resolve(null);\n",
              "    };\n",
              "  });\n",
              "\n",
              "  // Wait for the user to pick the files.\n",
              "  const files = yield {\n",
              "    promise: Promise.race([pickedPromise, cancelPromise]),\n",
              "    response: {\n",
              "      action: 'starting',\n",
              "    }\n",
              "  };\n",
              "\n",
              "  cancel.remove();\n",
              "\n",
              "  // Disable the input element since further picks are not allowed.\n",
              "  inputElement.disabled = true;\n",
              "\n",
              "  if (!files) {\n",
              "    return {\n",
              "      response: {\n",
              "        action: 'complete',\n",
              "      }\n",
              "    };\n",
              "  }\n",
              "\n",
              "  for (const file of files) {\n",
              "    const li = document.createElement('li');\n",
              "    li.append(span(file.name, {fontWeight: 'bold'}));\n",
              "    li.append(span(\n",
              "        `(${file.type || 'n/a'}) - ${file.size} bytes, ` +\n",
              "        `last modified: ${\n",
              "            file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() :\n",
              "                                    'n/a'} - `));\n",
              "    const percent = span('0% done');\n",
              "    li.appendChild(percent);\n",
              "\n",
              "    outputElement.appendChild(li);\n",
              "\n",
              "    const fileDataPromise = new Promise((resolve) => {\n",
              "      const reader = new FileReader();\n",
              "      reader.onload = (e) => {\n",
              "        resolve(e.target.result);\n",
              "      };\n",
              "      reader.readAsArrayBuffer(file);\n",
              "    });\n",
              "    // Wait for the data to be ready.\n",
              "    let fileData = yield {\n",
              "      promise: fileDataPromise,\n",
              "      response: {\n",
              "        action: 'continue',\n",
              "      }\n",
              "    };\n",
              "\n",
              "    // Use a chunked sending to avoid message size limits. See b/62115660.\n",
              "    let position = 0;\n",
              "    do {\n",
              "      const length = Math.min(fileData.byteLength - position, MAX_PAYLOAD_SIZE);\n",
              "      const chunk = new Uint8Array(fileData, position, length);\n",
              "      position += length;\n",
              "\n",
              "      const base64 = btoa(String.fromCharCode.apply(null, chunk));\n",
              "      yield {\n",
              "        response: {\n",
              "          action: 'append',\n",
              "          file: file.name,\n",
              "          data: base64,\n",
              "        },\n",
              "      };\n",
              "\n",
              "      let percentDone = fileData.byteLength === 0 ?\n",
              "          100 :\n",
              "          Math.round((position / fileData.byteLength) * 100);\n",
              "      percent.textContent = `${percentDone}% done`;\n",
              "\n",
              "    } while (position < fileData.byteLength);\n",
              "  }\n",
              "\n",
              "  // All done.\n",
              "  yield {\n",
              "    response: {\n",
              "      action: 'complete',\n",
              "    }\n",
              "  };\n",
              "}\n",
              "\n",
              "scope.google = scope.google || {};\n",
              "scope.google.colab = scope.google.colab || {};\n",
              "scope.google.colab._files = {\n",
              "  _uploadFiles,\n",
              "  _uploadFilesContinue,\n",
              "};\n",
              "})(self);\n",
              "</script> "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Saving kidney_disease (1).csv to kidney_disease (1) (1).csv\n",
            "Dataset Dimensions: (398, 25)\n",
            "\n",
            "Dataset Preview:\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "    age    bp     sg   al   su     rbc        pc         pcc          ba  \\\n",
              "0  48.0  80.0  1.020  1.0  0.0     NaN    normal  notpresent  notpresent   \n",
              "1   7.0  50.0  1.020  4.0  0.0     NaN    normal  notpresent  notpresent   \n",
              "2  62.0  80.0  1.010  2.0  3.0  normal    normal  notpresent  notpresent   \n",
              "3  48.0  70.0  1.005  4.0  0.0  normal  abnormal     present  notpresent   \n",
              "4  51.0  80.0  1.010  2.0  0.0  normal    normal  notpresent  notpresent   \n",
              "\n",
              "     bgr  ...  pcv    wc   rc  htn   dm cad appet   pe  ane classification  \n",
              "0  121.0  ...   44  7800  5.2  yes  yes  no  good   no   no            ckd  \n",
              "1    NaN  ...   38  6000  NaN   no   no  no  good   no   no            ckd  \n",
              "2  423.0  ...   31  7500  NaN   no  yes  no  poor   no  yes            ckd  \n",
              "3  117.0  ...   32  6700  3.9  yes   no  no  poor  yes  yes            ckd  \n",
              "4  106.0  ...   35  7300  4.6   no   no  no  good   no   no            ckd  \n",
              "\n",
              "[5 rows x 25 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-9098c617-e955-4e4c-b2ab-ea57a22ebafd\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>age</th>\n",
              "      <th>bp</th>\n",
              "      <th>sg</th>\n",
              "      <th>al</th>\n",
              "      <th>su</th>\n",
              "      <th>rbc</th>\n",
              "      <th>pc</th>\n",
              "      <th>pcc</th>\n",
              "      <th>ba</th>\n",
              "      <th>bgr</th>\n",
              "      <th>...</th>\n",
              "      <th>pcv</th>\n",
              "      <th>wc</th>\n",
              "      <th>rc</th>\n",
              "      <th>htn</th>\n",
              "      <th>dm</th>\n",
              "      <th>cad</th>\n",
              "      <th>appet</th>\n",
              "      <th>pe</th>\n",
              "      <th>ane</th>\n",
              "      <th>classification</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>48.0</td>\n",
              "      <td>80.0</td>\n",
              "      <td>1.020</td>\n",
              "      <td>1.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>normal</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>121.0</td>\n",
              "      <td>...</td>\n",
              "      <td>44</td>\n",
              "      <td>7800</td>\n",
              "      <td>5.2</td>\n",
              "      <td>yes</td>\n",
              "      <td>yes</td>\n",
              "      <td>no</td>\n",
              "      <td>good</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>ckd</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>7.0</td>\n",
              "      <td>50.0</td>\n",
              "      <td>1.020</td>\n",
              "      <td>4.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>NaN</td>\n",
              "      <td>normal</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>NaN</td>\n",
              "      <td>...</td>\n",
              "      <td>38</td>\n",
              "      <td>6000</td>\n",
              "      <td>NaN</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>good</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>ckd</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>62.0</td>\n",
              "      <td>80.0</td>\n",
              "      <td>1.010</td>\n",
              "      <td>2.0</td>\n",
              "      <td>3.0</td>\n",
              "      <td>normal</td>\n",
              "      <td>normal</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>423.0</td>\n",
              "      <td>...</td>\n",
              "      <td>31</td>\n",
              "      <td>7500</td>\n",
              "      <td>NaN</td>\n",
              "      <td>no</td>\n",
              "      <td>yes</td>\n",
              "      <td>no</td>\n",
              "      <td>poor</td>\n",
              "      <td>no</td>\n",
              "      <td>yes</td>\n",
              "      <td>ckd</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>48.0</td>\n",
              "      <td>70.0</td>\n",
              "      <td>1.005</td>\n",
              "      <td>4.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>normal</td>\n",
              "      <td>abnormal</td>\n",
              "      <td>present</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>117.0</td>\n",
              "      <td>...</td>\n",
              "      <td>32</td>\n",
              "      <td>6700</td>\n",
              "      <td>3.9</td>\n",
              "      <td>yes</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>poor</td>\n",
              "      <td>yes</td>\n",
              "      <td>yes</td>\n",
              "      <td>ckd</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>51.0</td>\n",
              "      <td>80.0</td>\n",
              "      <td>1.010</td>\n",
              "      <td>2.0</td>\n",
              "      <td>0.0</td>\n",
              "      <td>normal</td>\n",
              "      <td>normal</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>notpresent</td>\n",
              "      <td>106.0</td>\n",
              "      <td>...</td>\n",
              "      <td>35</td>\n",
              "      <td>7300</td>\n",
              "      <td>4.6</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>good</td>\n",
              "      <td>no</td>\n",
              "      <td>no</td>\n",
              "      <td>ckd</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 25 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-9098c617-e955-4e4c-b2ab-ea57a22ebafd')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-9098c617-e955-4e4c-b2ab-ea57a22ebafd button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-9098c617-e955-4e4c-b2ab-ea57a22ebafd');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-f1978255-78bb-41b5-abaa-66c274201045\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-f1978255-78bb-41b5-abaa-66c274201045')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-f1978255-78bb-41b5-abaa-66c274201045 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe"
            }
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Data Cleaning\n",
        "# Replace empty strings with NaN for proper handling\n",
        "data = pd.read_csv('kidney_disease (1).csv')\n",
        "data = data.replace('', np.nan)"
      ],
      "metadata": {
        "id": "mJk6_SmFQphh"
      },
      "execution_count": 17,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Impute missing values with mode for categorical columns and median for numerical\n",
        "for column in data.columns:\n",
        "    if data[column].dtype == 'object':\n",
        "        data[column] = data[column].fillna(data[column].mode()[0])\n",
        "    else:\n",
        "        data[column] = data[column].fillna(data[column].median())"
      ],
      "metadata": {
        "id": "aG0YAa0xQxDT"
      },
      "execution_count": 18,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Convert categorical features to numerical data.\n",
        "label_encoders = {}\n",
        "for column in data.select_dtypes(include=['object']).columns:\n",
        "    le = LabelEncoder()\n",
        "    data[column] = le.fit_transform(data[column])\n",
        "    label_encoders[column] = le"
      ],
      "metadata": {
        "id": "SB_QvHEgQzt7"
      },
      "execution_count": 19,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Define features and target variable\n",
        "X = data.drop('classification', axis=1).values\n",
        "y = data['classification'].values\n",
        "\n",
        "# Splitting data\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30, random_state=42)\n",
        "\n",
        "# Feature Scaling\n",
        "scaler = StandardScaler()\n",
        "X_train = scaler.fit_transform(X_train)\n",
        "X_test = scaler.transform(X_test)"
      ],
      "metadata": {
        "id": "RHAAmJZQQ17O"
      },
      "execution_count": 21,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Function for Model Evaluation ---\n",
        "def evaluate_model(model, model_name, X_test, y_test):\n",
        "    y_pred = model.predict(X_test)\n",
        "    accuracy = accuracy_score(y_test, y_pred)\n",
        "    report = classification_report(y_test, y_pred, zero_division=0)\n",
        "    print(f\"--------------------{model_name}--------------------\")\n",
        "    print(f\"Accuracy: {accuracy:.4f}\")\n",
        "    print(\"Classification Report:\\n\", report)"
      ],
      "metadata": {
        "id": "ZvuIQhsRQ-7Q"
      },
      "execution_count": 22,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Function for Grid Search ---\n",
        "def grid_search_model(model, param_grid, model_name, X_train, y_train, X_test, y_test):\n",
        "    grid = GridSearchCV(model, param_grid, cv=3, scoring='accuracy', verbose=0)\n",
        "    grid.fit(X_train, y_train)\n",
        "    print(f\"Best parameters for {model_name}: {grid.best_params_}\")\n",
        "    evaluate_model(grid.best_estimator_, model_name, X_test, y_test)\n",
        "    return grid.best_estimator_"
      ],
      "metadata": {
        "id": "_c8zEkN9RB7Y"
      },
      "execution_count": 23,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Function for Feature Selection (SelectKBest) ---\n",
        "def select_k_best_features(X, y, k=10):\n",
        "    selector = SelectKBest(score_func=f_classif, k=k)\n",
        "    X_new = selector.fit_transform(X, y)\n",
        "    selected_features = X.columns[selector.get_support()]\n",
        "    return X_new, selected_features"
      ],
      "metadata": {
        "id": "mprr5yOxREl_"
      },
      "execution_count": 24,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Function for Feature Selection (Tree-based) ---\n",
        "def tree_based_feature_selection(X, y, k=10):\n",
        "    model = ExtraTreesClassifier(n_estimators=100, random_state=42)\n",
        "    model.fit(X, y)\n",
        "    feature_importances = pd.Series(model.feature_importances_, index=X.columns)\n",
        "    selected_features = feature_importances.nlargest(k).index\n",
        "    X_new = X[selected_features]\n",
        "    return X_new, selected_features"
      ],
      "metadata": {
        "id": "oVR84hsCRG_Y"
      },
      "execution_count": 25,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Models and Parameter Grids ---\n",
        "models = {\n",
        "    'LogisticRegression': (LogisticRegression(max_iter=1000),\n",
        "                           {'C': [0.1, 1.0, 10.0], 'solver': ['liblinear', 'saga']}),\n",
        "    'DecisionTreeClassifier': (DecisionTreeClassifier(random_state=42),\n",
        "                               {'max_depth': [5, 10, 15], 'min_samples_leaf': [2, 5, 10]}),\n",
        "    'RandomForestClassifier': (RandomForestClassifier(random_state=42),\n",
        "                               {'n_estimators': [50, 100, 200], 'max_depth': [5, 10, 15], 'min_samples_leaf': [2, 5, 10]}),\n",
        "    'SVC': (SVC(random_state=42),\n",
        "            {'C': [0.1, 1, 10], 'kernel': ['linear', 'rbf'], 'gamma': ['scale', 'auto']}),\n",
        "    'GaussianNB': (GaussianNB(), {}),\n",
        "    'KNeighborsClassifier': (KNeighborsClassifier(),\n",
        "                            {'n_neighbors': [3, 5, 7], 'weights': ['uniform', 'distance']}),\n",
        "    'GradientBoostingClassifier': (GradientBoostingClassifier(random_state=42),\n",
        "                                  {'n_estimators': [50, 100, 200], 'learning_rate': [0.01, 0.1, 0.2], 'max_depth': [3, 5, 7]})\n",
        "}"
      ],
      "metadata": {
        "id": "2nkK2mfWRKGa"
      },
      "execution_count": 26,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Apply models with Grid Search ---\n",
        "print(\"-------------------Models with Grid Search-------------------\")\n",
        "for model_name, (model, param_grid) in models.items():\n",
        "    best_model = grid_search_model(model, param_grid, model_name, X_train, y_train, X_test, y_test)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "UzsmVeyZRNq4",
        "outputId": "e232bcf8-431d-45e0-a0a8-266b699a981f"
      },
      "execution_count": 27,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "-------------------Models with Grid Search-------------------\n",
            "Best parameters for LogisticRegression: {'C': 0.1, 'solver': 'saga'}\n",
            "--------------------LogisticRegression--------------------\n",
            "Accuracy: 0.9833\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.97      0.99        76\n",
            "           1       0.96      1.00      0.98        44\n",
            "\n",
            "    accuracy                           0.98       120\n",
            "   macro avg       0.98      0.99      0.98       120\n",
            "weighted avg       0.98      0.98      0.98       120\n",
            "\n",
            "Best parameters for DecisionTreeClassifier: {'max_depth': 5, 'min_samples_leaf': 2}\n",
            "--------------------DecisionTreeClassifier--------------------\n",
            "Accuracy: 0.9917\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.99      0.99        76\n",
            "           1       0.98      1.00      0.99        44\n",
            "\n",
            "    accuracy                           0.99       120\n",
            "   macro avg       0.99      0.99      0.99       120\n",
            "weighted avg       0.99      0.99      0.99       120\n",
            "\n",
            "Best parameters for RandomForestClassifier: {'max_depth': 5, 'min_samples_leaf': 5, 'n_estimators': 50}\n",
            "--------------------RandomForestClassifier--------------------\n",
            "Accuracy: 1.0000\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      1.00      1.00        76\n",
            "           1       1.00      1.00      1.00        44\n",
            "\n",
            "    accuracy                           1.00       120\n",
            "   macro avg       1.00      1.00      1.00       120\n",
            "weighted avg       1.00      1.00      1.00       120\n",
            "\n",
            "Best parameters for SVC: {'C': 1, 'gamma': 'scale', 'kernel': 'rbf'}\n",
            "--------------------SVC--------------------\n",
            "Accuracy: 0.9750\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.96      0.98        76\n",
            "           1       0.94      1.00      0.97        44\n",
            "\n",
            "    accuracy                           0.97       120\n",
            "   macro avg       0.97      0.98      0.97       120\n",
            "weighted avg       0.98      0.97      0.98       120\n",
            "\n",
            "Best parameters for GaussianNB: {}\n",
            "--------------------GaussianNB--------------------\n",
            "Accuracy: 0.9500\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.92      0.96        76\n",
            "           1       0.88      1.00      0.94        44\n",
            "\n",
            "    accuracy                           0.95       120\n",
            "   macro avg       0.94      0.96      0.95       120\n",
            "weighted avg       0.96      0.95      0.95       120\n",
            "\n",
            "Best parameters for KNeighborsClassifier: {'n_neighbors': 3, 'weights': 'uniform'}\n",
            "--------------------KNeighborsClassifier--------------------\n",
            "Accuracy: 0.9500\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.92      0.96        76\n",
            "           1       0.88      1.00      0.94        44\n",
            "\n",
            "    accuracy                           0.95       120\n",
            "   macro avg       0.94      0.96      0.95       120\n",
            "weighted avg       0.96      0.95      0.95       120\n",
            "\n",
            "Best parameters for GradientBoostingClassifier: {'learning_rate': 0.01, 'max_depth': 7, 'n_estimators': 100}\n",
            "--------------------GradientBoostingClassifier--------------------\n",
            "Accuracy: 0.9500\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.92      0.96        76\n",
            "           1       0.88      1.00      0.94        44\n",
            "\n",
            "    accuracy                           0.95       120\n",
            "   macro avg       0.94      0.96      0.95       120\n",
            "weighted avg       0.96      0.95      0.95       120\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Feature Selection (SelectKBest) ---\n",
        "print(\"\\n-------------------Feature Selection with SelectKBest-------------------\")\n",
        "X_df = pd.DataFrame(X, columns=data.drop('classification', axis=1).columns)\n",
        "X_new_kbest, selected_features_kbest = select_k_best_features(X_df, y)\n",
        "print(\"Selected features (SelectKBest):\", selected_features_kbest)\n",
        "\n",
        "X_train_kbest, X_test_kbest, y_train_kbest, y_test_kbest = train_test_split(X_new_kbest, y, test_size=0.30, random_state=42)\n",
        "X_train_kbest = scaler.fit_transform(X_train_kbest)\n",
        "X_test_kbest = scaler.transform(X_test_kbest)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6BSv_pW-RRaf",
        "outputId": "ae032372-7125-4955-b63c-d69ed8d44827"
      },
      "execution_count": 28,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "-------------------Feature Selection with SelectKBest-------------------\n",
            "Selected features (SelectKBest): Index(['sg', 'al', 'bgr', 'hemo', 'pcv', 'rc', 'htn', 'dm', 'appet', 'pe'], dtype='object')\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Apply models to SelectKBest features ---\n",
        "print(\"\\n-------------------Models with SelectKBest Features-------------------\")\n",
        "for model_name, (model, param_grid) in models.items():\n",
        "    if model_name == 'GaussianNB':\n",
        "        model.fit(X_train_kbest, y_train_kbest)\n",
        "        evaluate_model(model, model_name, X_test_kbest, y_test_kbest)\n",
        "    else:\n",
        "        best_model_kbest = grid_search_model(model, param_grid, model_name, X_train_kbest, y_train_kbest, X_test_kbest, y_test_kbest)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "GZXGfooXRe8F",
        "outputId": "9f63ce7e-8626-44e5-a44b-09f005b59cd0"
      },
      "execution_count": 29,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "-------------------Models with SelectKBest Features-------------------\n",
            "Best parameters for LogisticRegression: {'C': 0.1, 'solver': 'saga'}\n",
            "--------------------LogisticRegression--------------------\n",
            "Accuracy: 0.9667\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.95      0.97        76\n",
            "           1       0.92      1.00      0.96        44\n",
            "\n",
            "    accuracy                           0.97       120\n",
            "   macro avg       0.96      0.97      0.96       120\n",
            "weighted avg       0.97      0.97      0.97       120\n",
            "\n",
            "Best parameters for DecisionTreeClassifier: {'max_depth': 5, 'min_samples_leaf': 5}\n",
            "--------------------DecisionTreeClassifier--------------------\n",
            "Accuracy: 0.9917\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.99      0.99        76\n",
            "           1       0.98      1.00      0.99        44\n",
            "\n",
            "    accuracy                           0.99       120\n",
            "   macro avg       0.99      0.99      0.99       120\n",
            "weighted avg       0.99      0.99      0.99       120\n",
            "\n",
            "Best parameters for RandomForestClassifier: {'max_depth': 5, 'min_samples_leaf': 2, 'n_estimators': 100}\n",
            "--------------------RandomForestClassifier--------------------\n",
            "Accuracy: 1.0000\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      1.00      1.00        76\n",
            "           1       1.00      1.00      1.00        44\n",
            "\n",
            "    accuracy                           1.00       120\n",
            "   macro avg       1.00      1.00      1.00       120\n",
            "weighted avg       1.00      1.00      1.00       120\n",
            "\n",
            "Best parameters for SVC: {'C': 1, 'gamma': 'scale', 'kernel': 'rbf'}\n",
            "--------------------SVC--------------------\n",
            "Accuracy: 0.9833\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.97      0.99        76\n",
            "           1       0.96      1.00      0.98        44\n",
            "\n",
            "    accuracy                           0.98       120\n",
            "   macro avg       0.98      0.99      0.98       120\n",
            "weighted avg       0.98      0.98      0.98       120\n",
            "\n",
            "--------------------GaussianNB--------------------\n",
            "Accuracy: 0.9250\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.88      0.94        76\n",
            "           1       0.83      1.00      0.91        44\n",
            "\n",
            "    accuracy                           0.93       120\n",
            "   macro avg       0.92      0.94      0.92       120\n",
            "weighted avg       0.94      0.93      0.93       120\n",
            "\n",
            "Best parameters for KNeighborsClassifier: {'n_neighbors': 3, 'weights': 'uniform'}\n",
            "--------------------KNeighborsClassifier--------------------\n",
            "Accuracy: 0.9750\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.96      0.98        76\n",
            "           1       0.94      1.00      0.97        44\n",
            "\n",
            "    accuracy                           0.97       120\n",
            "   macro avg       0.97      0.98      0.97       120\n",
            "weighted avg       0.98      0.97      0.98       120\n",
            "\n",
            "Best parameters for GradientBoostingClassifier: {'learning_rate': 0.1, 'max_depth': 3, 'n_estimators': 50}\n",
            "--------------------GradientBoostingClassifier--------------------\n",
            "Accuracy: 1.0000\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      1.00      1.00        76\n",
            "           1       1.00      1.00      1.00        44\n",
            "\n",
            "    accuracy                           1.00       120\n",
            "   macro avg       1.00      1.00      1.00       120\n",
            "weighted avg       1.00      1.00      1.00       120\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "# --- Feature Selection (Tree-based) ---\n",
        "print(\"\\n-------------------Feature Selection with Tree-based method-------------------\")\n",
        "X_new_tree, selected_features_tree = tree_based_feature_selection(X_df, y)\n",
        "print(\"Selected features (Tree-based):\", selected_features_tree)\n",
        "\n",
        "X_train_tree, X_test_tree, y_train_tree, y_test_tree = train_test_split(X_new_tree, y, test_size=0.30, random_state=42)\n",
        "X_train_tree = scaler.fit_transform(X_train_tree)\n",
        "X_test_tree = scaler.transform(X_test_tree)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "lgtQfsVtRjkO",
        "outputId": "2399b9a7-e471-406e-a0e7-421224f4d34e"
      },
      "execution_count": 30,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "-------------------Feature Selection with Tree-based method-------------------\n",
            "Selected features (Tree-based): Index(['sg', 'htn', 'hemo', 'al', 'pcv', 'dm', 'appet', 'rc', 'pe', 'pc'], dtype='object')\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# --- Apply models to Tree-based features ---\n",
        "print(\"\\n-------------------Models with Tree-based Features-------------------\")\n",
        "for model_name, (model, param_grid) in models.items():\n",
        "    if model_name == 'GaussianNB':\n",
        "        model.fit(X_train_tree, y_train_tree)\n",
        "        evaluate_model(model, model_name, X_test_tree, y_test_tree)\n",
        "    else:\n",
        "        best_model_tree = grid_search_model(model, param_grid, model_name, X_train_tree, y_train_tree, X_test_tree, y_test_tree)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "GG5lJcNqRyYI",
        "outputId": "a8fcabf0-7363-4179-8dcb-300d18bff82b"
      },
      "execution_count": 31,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\n",
            "-------------------Models with Tree-based Features-------------------\n",
            "Best parameters for LogisticRegression: {'C': 0.1, 'solver': 'saga'}\n",
            "--------------------LogisticRegression--------------------\n",
            "Accuracy: 0.9750\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.96      0.98        76\n",
            "           1       0.94      1.00      0.97        44\n",
            "\n",
            "    accuracy                           0.97       120\n",
            "   macro avg       0.97      0.98      0.97       120\n",
            "weighted avg       0.98      0.97      0.98       120\n",
            "\n",
            "Best parameters for DecisionTreeClassifier: {'max_depth': 10, 'min_samples_leaf': 2}\n",
            "--------------------DecisionTreeClassifier--------------------\n",
            "Accuracy: 0.9917\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.99      0.99        76\n",
            "           1       0.98      1.00      0.99        44\n",
            "\n",
            "    accuracy                           0.99       120\n",
            "   macro avg       0.99      0.99      0.99       120\n",
            "weighted avg       0.99      0.99      0.99       120\n",
            "\n",
            "Best parameters for RandomForestClassifier: {'max_depth': 5, 'min_samples_leaf': 2, 'n_estimators': 50}\n",
            "--------------------RandomForestClassifier--------------------\n",
            "Accuracy: 1.0000\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      1.00      1.00        76\n",
            "           1       1.00      1.00      1.00        44\n",
            "\n",
            "    accuracy                           1.00       120\n",
            "   macro avg       1.00      1.00      1.00       120\n",
            "weighted avg       1.00      1.00      1.00       120\n",
            "\n",
            "Best parameters for SVC: {'C': 1, 'gamma': 'scale', 'kernel': 'rbf'}\n",
            "--------------------SVC--------------------\n",
            "Accuracy: 0.9750\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.96      0.98        76\n",
            "           1       0.94      1.00      0.97        44\n",
            "\n",
            "    accuracy                           0.97       120\n",
            "   macro avg       0.97      0.98      0.97       120\n",
            "weighted avg       0.98      0.97      0.98       120\n",
            "\n",
            "--------------------GaussianNB--------------------\n",
            "Accuracy: 0.9333\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.89      0.94        76\n",
            "           1       0.85      1.00      0.92        44\n",
            "\n",
            "    accuracy                           0.93       120\n",
            "   macro avg       0.92      0.95      0.93       120\n",
            "weighted avg       0.94      0.93      0.93       120\n",
            "\n",
            "Best parameters for KNeighborsClassifier: {'n_neighbors': 7, 'weights': 'uniform'}\n",
            "--------------------KNeighborsClassifier--------------------\n",
            "Accuracy: 0.9417\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.91      0.95        76\n",
            "           1       0.86      1.00      0.93        44\n",
            "\n",
            "    accuracy                           0.94       120\n",
            "   macro avg       0.93      0.95      0.94       120\n",
            "weighted avg       0.95      0.94      0.94       120\n",
            "\n",
            "Best parameters for GradientBoostingClassifier: {'learning_rate': 0.01, 'max_depth': 3, 'n_estimators': 50}\n",
            "--------------------GradientBoostingClassifier--------------------\n",
            "Accuracy: 0.9917\n",
            "Classification Report:\n",
            "               precision    recall  f1-score   support\n",
            "\n",
            "           0       1.00      0.99      0.99        76\n",
            "           1       0.98      1.00      0.99        44\n",
            "\n",
            "    accuracy                           0.99       120\n",
            "   macro avg       0.99      0.99      0.99       120\n",
            "weighted avg       0.99      0.99      0.99       120\n",
            "\n"
          ]
        }
      ]
    }
  ]
}