YBIFoundation / Fundamental

Jupyter Notebook
1.7k stars 783 forks source link

Man with instruments #18

Open pavansai9944 opened 8 months ago

pavansai9944 commented 8 months ago

{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# YBI Foundation" ], "metadata": { "id": "udzb8fLnATPo" } }, { "cell_type": "markdown", "source": [ "Join Telegram to Get Updates of all Future FREE Bootcamps and Courses" ], "metadata": { "id": "vzL7ma3AATPp" } }, { "cell_type": "markdown", "source": [ "# Train Test Split" ], "metadata": { "id": "aw6GdUmOATPq" } }, { "cell_type": "markdown", "source": [ "Watch Video Tutorial" ], "metadata": { "id": "Fx4DYyExATPq" } }, { "cell_type": "code", "source": [ "# import library\n", "import pandas as pd" ], "metadata": { "id": "qcdlHsRIATPr" }, "execution_count": 1, "outputs": [] }, { "cell_type": "code", "source": [ "# read data\n", "diabetes = pd.read_csv('https://github.com/YBIFoundation/Dataset/raw/main/Diabetes.csv')" ], "metadata": { "id": "8J7uChqZATPr" }, "execution_count": 2, "outputs": [] }, { "cell_type": "code", "source": [ "# display first 5 rows\n", "diabetes.head()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "outputId": "919feef7-17ec-4615-de43-ce1df4c929ec", "id": "ZEo_mcDkATPs" }, "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " pregnancies glucose diastolic triceps insulin bmi dpf age \\n", "0 6 148 72 35 0 33.6 0.627 50 \n", "1 1 85 66 29 0 26.6 0.351 31 \n", "2 8 183 64 0 0 23.3 0.672 32 \n", "3 1 89 66 23 94 28.1 0.167 21 \n", "4 0 137 40 35 168 43.1 2.288 33 \n", "\n", " diabetes \n", "0 1 \n", "1 0 \n", "2 1 \n", "3 0 \n", "4 1 " ], "text/html": [ "\n", " <div id=\"df-821c7e62-e558-40d5-9bb3-a1e1eee6cf0b\">\n", " <div class=\"colab-df-container\">\n", "

\n", "\n", "<table border=\"1\" class=\"dataframe\">\n", " \n", " <tr style=\"text-align: right;\">\n", " \n", " pregnancies\n", " glucose\n", " diastolic\n", " triceps\n", " insulin\n", " bmi\n", " dpf\n", " age\n", " diabetes\n", " \n", " \n", " \n", " \n", " 0\n", " 6\n", " 148\n", " 72\n", " 35\n", " 0\n", " 33.6\n", " 0.627\n", " 50\n", " 1\n", " \n", " \n", " 1\n", " 1\n", " 85\n", " 66\n", " 29\n", " 0\n", " 26.6\n", " 0.351\n", " 31\n", " 0\n", " \n", " \n", " 2\n", " 8\n", " 183\n", " 64\n", " 0\n", " 0\n", " 23.3\n", " 0.672\n", " 32\n", " 1\n", " \n", " \n", " 3\n", " 1\n", " 89\n", " 66\n", " 23\n", " 94\n", " 28.1\n", " 0.167\n", " 21\n", " 0\n", " \n", " \n", " 4\n", " 0\n", " 137\n", " 40\n", " 35\n", " 168\n", " 43.1\n", " 2.288\n", " 33\n", " 1\n", " \n", " \n", "\n", "
\n", " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-821c7e62-e558-40d5-9bb3-a1e1eee6cf0b')\"\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 0 24 24\"\n", " width=\"24px\">\n", " <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", " <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", " \n", " \n", " \n", " \n", "\n", " \n", "
\n", "
\n", " " ] }, "metadata": {}, "execution_count": 3 } ] }, { "cell_type": "code", "source": [ "# display columns\n", "diabetes.columns" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "S78U0fRHAkPL", "outputId": "b7bc2517-30c5-4fba-8a83-bbfe204f54de" }, "execution_count": 4, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "Index(['pregnancies', 'glucose', 'diastolic', 'triceps', 'insulin', 'bmi',\n", " 'dpf', 'age', 'diabetes'],\n", " dtype='object')" ] }, "metadata": {}, "execution_count": 4 } ] }, { "cell_type": "code", "source": [ "# define target (y)\n", "y = diabetes['diabetes']" ], "metadata": { "id": "79-uJsofAa8v" }, "execution_count": 5, "outputs": [] }, { "cell_type": "code", "source": [ "# define features (X)\n", "X = diabetes.drop(['diabetes'], axis=1)" ], "metadata": { "id": "jrxtDWL5AbAU" }, "execution_count": 6, "outputs": [] }, { "cell_type": "code", "source": [ "X = diabetes[['pregnancies', 'glucose', 'diastolic', 'triceps', 'insulin', 'bmi',\n", " 'dpf', 'age']]" ], "metadata": { "id": "rzq8Z5UaAbD0" }, "execution_count": 7, "outputs": [] }, { "cell_type": "code", "source": [ "# import train test split function\n", "from sklearn.model_selection import train_test_split" ], "metadata": { "id": "d92dcKtbAbHD" }, "execution_count": 8, "outputs": [] }, { "cell_type": "code", "source": [ "X_train,X_test,y_train,y_test=train_test_split(X,y,train_size=0.7,stratify=y,random_state=2529)" ], "metadata": { "id": "es-YyCT_AbKi" }, "execution_count": 9, "outputs": [] }, { "cell_type": "code", "source": [ "X_train.shape,X_test.shape,y_train.shape,y_test.shape" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "GqC8_uuOAbN5", "outputId": "67db06c7-c98f-41ec-e490-b093e0a9549a" }, "execution_count": 10, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "((537, 8), (231, 8), (537,), (231,))" ] }, "metadata": {}, "execution_count": 10 } ] }, { "cell_type": "code", "source": [ "X_train" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "id": "xvNb8DNbAbQ8", "outputId": "fffbe436-94ec-4467-e5dd-bd9d325848df" }, "execution_count": 11, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " pregnancies glucose diastolic triceps insulin bmi dpf age\n", "377 1 87 60 37 75 37.2 0.509 22\n", "393 4 116 72 12 87 22.1 0.463 37\n", "662 8 167 106 46 231 37.6 0.165 43\n", "367 0 101 64 17 0 21.0 0.252 21\n", "233 4 122 68 0 0 35.0 0.394 29\n", ".. ... ... ... ... ... ... ... ...\n", "689 1 144 82 46 180 46.1 0.335 46\n", "730 3 130 78 23 79 28.4 0.323 34\n", "464 10 115 98 0 0 24.0 1.022 34\n", "223 7 142 60 33 190 28.8 0.687 61\n", "485 0 135 68 42 250 42.3 0.365 24\n", "\n", "[537 rows x 8 columns]" ], "text/html": [ "\n", " <div id=\"df-28c0cf33-79c7-4643-82a1-41f832a06404\">\n", " <div class=\"colab-df-container\">\n", "
\n", "\n", "<table border=\"1\" class=\"dataframe\">\n", " \n", " <tr style=\"text-align: right;\">\n", " \n", " pregnancies\n", " glucose\n", " diastolic\n", " triceps\n", " insulin\n", " bmi\n", " dpf\n", " age\n", " \n", " \n", " \n", " \n", " 377\n", " 1\n", " 87\n", " 60\n", " 37\n", " 75\n", " 37.2\n", " 0.509\n", " 22\n", " \n", " \n", " 393\n", " 4\n", " 116\n", " 72\n", " 12\n", " 87\n", " 22.1\n", " 0.463\n", " 37\n", " \n", " \n", " 662\n", " 8\n", " 167\n", " 106\n", " 46\n", " 231\n", " 37.6\n", " 0.165\n", " 43\n", " \n", " \n", " 367\n", " 0\n", " 101\n", " 64\n", " 17\n", " 0\n", " 21.0\n", " 0.252\n", " 21\n", " \n", " \n", " 233\n", " 4\n", " 122\n", " 68\n", " 0\n", " 0\n", " 35.0\n", " 0.394\n", " 29\n", " \n", " \n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " \n", " \n", " 689\n", " 1\n", " 144\n", " 82\n", " 46\n", " 180\n", " 46.1\n", " 0.335\n", " 46\n", " \n", " \n", " 730\n", " 3\n", " 130\n", " 78\n", " 23\n", " 79\n", " 28.4\n", " 0.323\n", " 34\n", " \n", " \n", " 464\n", " 10\n", " 115\n", " 98\n", " 0\n", " 0\n", " 24.0\n", " 1.022\n", " 34\n", " \n", " \n", " 223\n", " 7\n", " 142\n", " 60\n", " 33\n", " 190\n", " 28.8\n", " 0.687\n", " 61\n", " \n", " \n", " 485\n", " 0\n", " 135\n", " 68\n", " 42\n", " 250\n", " 42.3\n", " 0.365\n", " 24\n", " \n", " \n", "\n", "

537 rows × 8 columns

\n", "
\n", " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-28c0cf33-79c7-4643-82a1-41f832a06404')\"\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 0 24 24\"\n", " width=\"24px\">\n", " <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", " <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", " \n", " \n", " \n", " \n", "\n", " \n", " \n", " \n", " " ] }, "metadata": {}, "execution_count": 11 } ] }, { "cell_type": "markdown", "source": [ "# Don't Forget to Star and Watch on GitHub to Receive Updates\n", "Action 1: ⭐Star Repository as it make easy for you to find it again. You can see all the repositories and topics you have starred by going to your stars page.\n", "\n", "Action 2: 👁 Watch Repository and get notified of all future updates and activities in this repository.\n", "\n", "Click Here to Visit Fundamental Repository on GitHub" ], "metadata": { "id": "WJNgKSFRATP5" } }, { "cell_type": "markdown", "source": [ "image.png" ], "metadata": { "id": "mDod7pEaATP6" } }, { "cell_type": "markdown", "source": [ "# Don't Forget to Upvote NoteBook on Kaggle and Receive Updates \n", "Click Here to Visit Kaggle" ], "metadata": { "id": "XFb13-aBATP9" } }, { "cell_type": "markdown", "source": [ "image.png" ], "metadata": { "id": "-HpTOVa2ATP9" } } ] }