From 2feacfc0d9fdc5a1b51b41c4936cb78e3f15052b Mon Sep 17 00:00:00 2001
From: sunny491 <61613479+sunny491@users.noreply.github.com>
Date: Sat, 16 Oct 2021 20:20:27 +0530
Subject: [PATCH 1/3] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 27ac9c1..10ffe17 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Hacktoberfest
+# Hacktoberfest 2021
Projetos do grupo participando da Hacktoberfest 2018 (N⁰5)
# Lista.
From 6e6c66b4f817c16917379d2153ecca399f009674 Mon Sep 17 00:00:00 2001
From: sunny491 <61613479+sunny491@users.noreply.github.com>
Date: Sun, 11 Feb 2024 14:50:13 +0530
Subject: [PATCH 2/3] Created using Colaboratory
---
Chance_of_Admission_Predection.ipynb | 1154 ++++++++++++++++++++++++++
1 file changed, 1154 insertions(+)
create mode 100644 Chance_of_Admission_Predection.ipynb
diff --git a/Chance_of_Admission_Predection.ipynb b/Chance_of_Admission_Predection.ipynb
new file mode 100644
index 0000000..40d0752
--- /dev/null
+++ b/Chance_of_Admission_Predection.ipynb
@@ -0,0 +1,1154 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "authorship_tag": "ABX9TyOeQj2rpH0BPVlMRtcx/HnD",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "id": "yrLYghtfVcs3"
+ },
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "admission = pd.read_csv('https://github.com/ybifoundation/Dataset/raw/main/Admission%20Chance.csv')"
+ ],
+ "metadata": {
+ "id": "RaYs3OK4V6Vr"
+ },
+ "execution_count": 5,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "admission.head()\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "id": "pWPLlp2DWLXB",
+ "outputId": "30472869-0fd0-4ba1-93c4-f358d0d558b6"
+ },
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Serial No GRE Score TOEFL Score University Rating SOP LOR CGPA \\\n",
+ "0 1 337 118 4 4.5 4.5 9.65 \n",
+ "1 2 324 107 4 4.0 4.5 8.87 \n",
+ "2 3 316 104 3 3.0 3.5 8.00 \n",
+ "3 4 322 110 3 3.5 2.5 8.67 \n",
+ "4 5 314 103 2 2.0 3.0 8.21 \n",
+ "\n",
+ " Research Chance of Admit \n",
+ "0 1 0.92 \n",
+ "1 1 0.76 \n",
+ "2 1 0.72 \n",
+ "3 1 0.80 \n",
+ "4 0 0.65 "
+ ],
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Serial No | \n",
+ " GRE Score | \n",
+ " TOEFL Score | \n",
+ " University Rating | \n",
+ " SOP | \n",
+ " LOR | \n",
+ " CGPA | \n",
+ " Research | \n",
+ " Chance of Admit | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 337 | \n",
+ " 118 | \n",
+ " 4 | \n",
+ " 4.5 | \n",
+ " 4.5 | \n",
+ " 9.65 | \n",
+ " 1 | \n",
+ " 0.92 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 324 | \n",
+ " 107 | \n",
+ " 4 | \n",
+ " 4.0 | \n",
+ " 4.5 | \n",
+ " 8.87 | \n",
+ " 1 | \n",
+ " 0.76 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 3 | \n",
+ " 316 | \n",
+ " 104 | \n",
+ " 3 | \n",
+ " 3.0 | \n",
+ " 3.5 | \n",
+ " 8.00 | \n",
+ " 1 | \n",
+ " 0.72 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 4 | \n",
+ " 322 | \n",
+ " 110 | \n",
+ " 3 | \n",
+ " 3.5 | \n",
+ " 2.5 | \n",
+ " 8.67 | \n",
+ " 1 | \n",
+ " 0.80 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 314 | \n",
+ " 103 | \n",
+ " 2 | \n",
+ " 2.0 | \n",
+ " 3.0 | \n",
+ " 8.21 | \n",
+ " 0 | \n",
+ " 0.65 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 6
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "admission.info()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "cwLIL5DgWPQO",
+ "outputId": "9755d53b-695a-4185-8615-d59550704c73"
+ },
+ "execution_count": 7,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\n",
+ "RangeIndex: 400 entries, 0 to 399\n",
+ "Data columns (total 9 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 Serial No 400 non-null int64 \n",
+ " 1 GRE Score 400 non-null int64 \n",
+ " 2 TOEFL Score 400 non-null int64 \n",
+ " 3 University Rating 400 non-null int64 \n",
+ " 4 SOP 400 non-null float64\n",
+ " 5 LOR 400 non-null float64\n",
+ " 6 CGPA 400 non-null float64\n",
+ " 7 Research 400 non-null int64 \n",
+ " 8 Chance of Admit 400 non-null float64\n",
+ "dtypes: float64(4), int64(5)\n",
+ "memory usage: 28.2 KB\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "admission.describe()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 300
+ },
+ "id": "xsTBgAMQWWvI",
+ "outputId": "35473176-1bc1-4284-e1db-2eaae8cb311d"
+ },
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Serial No GRE Score TOEFL Score University Rating SOP \\\n",
+ "count 400.000000 400.000000 400.000000 400.000000 400.000000 \n",
+ "mean 200.500000 316.807500 107.410000 3.087500 3.400000 \n",
+ "std 115.614301 11.473646 6.069514 1.143728 1.006869 \n",
+ "min 1.000000 290.000000 92.000000 1.000000 1.000000 \n",
+ "25% 100.750000 308.000000 103.000000 2.000000 2.500000 \n",
+ "50% 200.500000 317.000000 107.000000 3.000000 3.500000 \n",
+ "75% 300.250000 325.000000 112.000000 4.000000 4.000000 \n",
+ "max 400.000000 340.000000 120.000000 5.000000 5.000000 \n",
+ "\n",
+ " LOR CGPA Research Chance of Admit \n",
+ "count 400.000000 400.000000 400.000000 400.000000 \n",
+ "mean 3.452500 8.598925 0.547500 0.724350 \n",
+ "std 0.898478 0.596317 0.498362 0.142609 \n",
+ "min 1.000000 6.800000 0.000000 0.340000 \n",
+ "25% 3.000000 8.170000 0.000000 0.640000 \n",
+ "50% 3.500000 8.610000 1.000000 0.730000 \n",
+ "75% 4.000000 9.062500 1.000000 0.830000 \n",
+ "max 5.000000 9.920000 1.000000 0.970000 "
+ ],
+ "text/html": [
+ "\n",
+ " \n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Serial No | \n",
+ " GRE Score | \n",
+ " TOEFL Score | \n",
+ " University Rating | \n",
+ " SOP | \n",
+ " LOR | \n",
+ " CGPA | \n",
+ " Research | \n",
+ " Chance of Admit | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " count | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ " 400.000000 | \n",
+ "
\n",
+ " \n",
+ " mean | \n",
+ " 200.500000 | \n",
+ " 316.807500 | \n",
+ " 107.410000 | \n",
+ " 3.087500 | \n",
+ " 3.400000 | \n",
+ " 3.452500 | \n",
+ " 8.598925 | \n",
+ " 0.547500 | \n",
+ " 0.724350 | \n",
+ "
\n",
+ " \n",
+ " std | \n",
+ " 115.614301 | \n",
+ " 11.473646 | \n",
+ " 6.069514 | \n",
+ " 1.143728 | \n",
+ " 1.006869 | \n",
+ " 0.898478 | \n",
+ " 0.596317 | \n",
+ " 0.498362 | \n",
+ " 0.142609 | \n",
+ "
\n",
+ " \n",
+ " min | \n",
+ " 1.000000 | \n",
+ " 290.000000 | \n",
+ " 92.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 1.000000 | \n",
+ " 6.800000 | \n",
+ " 0.000000 | \n",
+ " 0.340000 | \n",
+ "
\n",
+ " \n",
+ " 25% | \n",
+ " 100.750000 | \n",
+ " 308.000000 | \n",
+ " 103.000000 | \n",
+ " 2.000000 | \n",
+ " 2.500000 | \n",
+ " 3.000000 | \n",
+ " 8.170000 | \n",
+ " 0.000000 | \n",
+ " 0.640000 | \n",
+ "
\n",
+ " \n",
+ " 50% | \n",
+ " 200.500000 | \n",
+ " 317.000000 | \n",
+ " 107.000000 | \n",
+ " 3.000000 | \n",
+ " 3.500000 | \n",
+ " 3.500000 | \n",
+ " 8.610000 | \n",
+ " 1.000000 | \n",
+ " 0.730000 | \n",
+ "
\n",
+ " \n",
+ " 75% | \n",
+ " 300.250000 | \n",
+ " 325.000000 | \n",
+ " 112.000000 | \n",
+ " 4.000000 | \n",
+ " 4.000000 | \n",
+ " 4.000000 | \n",
+ " 9.062500 | \n",
+ " 1.000000 | \n",
+ " 0.830000 | \n",
+ "
\n",
+ " \n",
+ " max | \n",
+ " 400.000000 | \n",
+ " 340.000000 | \n",
+ " 120.000000 | \n",
+ " 5.000000 | \n",
+ " 5.000000 | \n",
+ " 5.000000 | \n",
+ " 9.920000 | \n",
+ " 1.000000 | \n",
+ " 0.970000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 8
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "admission.columns\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "19koCZ4kWb1r",
+ "outputId": "44856859-0ca2-4c12-a583-1729764a5c1b"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "Index(['Serial No', 'GRE Score', 'TOEFL Score', 'University Rating', ' SOP',\n",
+ " 'LOR ', 'CGPA', 'Research', 'Chance of Admit '],\n",
+ " dtype='object')"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y = admission['Chance of Admit ']\n"
+ ],
+ "metadata": {
+ "id": "70S3qdhSWdv1"
+ },
+ "execution_count": 11,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "X = admission.drop(['Serial No','Chance of Admit '],axis=1)\n"
+ ],
+ "metadata": {
+ "id": "rEo_AN5kWlKT"
+ },
+ "execution_count": 12,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.model_selection import train_test_split\n",
+ "X_train, X_test, y_train, y_test = train_test_split(X,y, train_size=0.7, random_state=2529)"
+ ],
+ "metadata": {
+ "id": "5_qbDK0jWr4x"
+ },
+ "execution_count": 13,
+ "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": "bbnehRVHWumd",
+ "outputId": "cb112fae-212b-474e-9356-13fb7fe4b3bc"
+ },
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "((280, 7), (120, 7), (280,), (120,))"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 14
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.linear_model import LinearRegression\n",
+ "model = LinearRegression()"
+ ],
+ "metadata": {
+ "id": "hz6bmYzdW2En"
+ },
+ "execution_count": 15,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.fit(X_train,y_train)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 75
+ },
+ "id": "fQ4dginmW5P_",
+ "outputId": "d6e6759a-496d-4bc8-ab0a-687a6a3a0a09"
+ },
+ "execution_count": 16,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "LinearRegression()"
+ ],
+ "text/html": [
+ "LinearRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org. "
+ ]
+ },
+ "metadata": {},
+ "execution_count": 16
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.intercept_\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "jGOAV_iXXAGR",
+ "outputId": "a1cf34bf-44ab-4958-dea3-82fd61c5ee14"
+ },
+ "execution_count": 17,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "-1.2831244932033998"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 17
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.coef_\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "cMyKaY6RXDYs",
+ "outputId": "383ce989-c861-4c21-959a-468ce9f824bc"
+ },
+ "execution_count": 18,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([ 0.00204057, 0.00287273, 0.00566887, -0.00380559, 0.01973175,\n",
+ " 0.11314449, 0.02061553])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 18
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y_pred = model.predict(X_test)\n"
+ ],
+ "metadata": {
+ "id": "OxvlFbP8XHG8"
+ },
+ "execution_count": 19,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y_pred\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "OQvmVLt4XKLT",
+ "outputId": "6d72d6b1-e379-4a44-9e33-beff34d8b71c"
+ },
+ "execution_count": 20,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([0.71426327, 0.72534136, 0.69677103, 0.66566584, 0.57483872,\n",
+ " 0.93087527, 0.93701113, 0.72361387, 0.81130158, 0.62223963,\n",
+ " 0.59629648, 0.80084072, 0.52537944, 0.79174558, 0.84064992,\n",
+ " 0.66429594, 0.65136589, 0.66990687, 0.75794085, 0.86072023,\n",
+ " 0.66088101, 0.85570763, 0.84777425, 0.95033179, 0.68750762,\n",
+ " 0.65907671, 0.65279623, 0.5709259 , 0.55895645, 0.57990205,\n",
+ " 0.54497918, 0.7570717 , 0.69682571, 0.77286067, 0.64320811,\n",
+ " 0.5183554 , 0.43816818, 0.84654064, 0.90398354, 0.80517781,\n",
+ " 0.72218971, 0.72882587, 0.68145136, 0.88592237, 0.77208852,\n",
+ " 0.78778085, 0.95526121, 0.88586486, 0.59980416, 0.50690214,\n",
+ " 0.59947098, 0.63380406, 0.82841217, 0.44911724, 0.71068577,\n",
+ " 0.77335748, 0.68851557, 0.64486026, 0.85537724, 0.65517768,\n",
+ " 0.65046031, 0.90818978, 0.63422429, 0.68658606, 0.72150268,\n",
+ " 0.69030545, 0.59381287, 0.93813035, 0.58997351, 0.91542587,\n",
+ " 0.59283415, 0.93351713, 0.59478751, 0.71380389, 0.54346237,\n",
+ " 0.84710913, 0.6084418 , 0.7257337 , 0.67545704, 0.81387503,\n",
+ " 0.70259527, 0.88600461, 0.67084016, 0.53064995, 0.77790726,\n",
+ " 0.65780713, 0.78970635, 0.54709634, 0.77924705, 0.66750436,\n",
+ " 0.69363338, 0.69891086, 0.92185813, 0.70469056, 0.62554306,\n",
+ " 0.62208829, 0.73828086, 0.67369114, 0.76391913, 0.61985049,\n",
+ " 0.92865957, 0.70430038, 0.9828821 , 0.82502993, 0.78261009,\n",
+ " 0.83438446, 0.66840368, 0.70165011, 0.64534281, 0.5715406 ,\n",
+ " 0.80739359, 0.69273815, 0.80585447, 0.6102703 , 0.54641206,\n",
+ " 0.76301749, 0.71080317, 0.6261331 , 0.83951248, 0.68578269])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 20
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.metrics import mean_absolute_error, mean_absolute_percentage_error, mean_squared_error"
+ ],
+ "metadata": {
+ "id": "fi1Nd3xUXN18"
+ },
+ "execution_count": 21,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "mean_absolute_error(y_test,y_pred)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "jxmTIRZeXRAB",
+ "outputId": "09fbf9b8-fdff-4e67-ad31-6a92663a2190"
+ },
+ "execution_count": 22,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.04400128934232651"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 22
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "mean_absolute_percentage_error(y_test,y_pred)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Klm8y5wFXTug",
+ "outputId": "dffa3324-58b1-4073-8f1b-fad1f1edca29"
+ },
+ "execution_count": 23,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.07575278864605438"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 23
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "mean_squared_error(y_test,y_pred)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "cuQWErYNXWUI",
+ "outputId": "5ece6280-415b-4466-c058-e40b0336abb3"
+ },
+ "execution_count": 24,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.004038263715495693"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 24
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From c67c3cdf2ae8280dffcc8fd30001a16f73e63d39 Mon Sep 17 00:00:00 2001
From: sunny491 <61613479+sunny491@users.noreply.github.com>
Date: Mon, 12 Feb 2024 13:15:49 +0530
Subject: [PATCH 3/3] Created using Colaboratory
---
Credit_Card_Default.ipynb | 1076 +++++++++++++++++++++++++++++++++++++
1 file changed, 1076 insertions(+)
create mode 100644 Credit_Card_Default.ipynb
diff --git a/Credit_Card_Default.ipynb b/Credit_Card_Default.ipynb
new file mode 100644
index 0000000..cc9acb1
--- /dev/null
+++ b/Credit_Card_Default.ipynb
@@ -0,0 +1,1076 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "authorship_tag": "ABX9TyMg9SdYRkCUwHVvod7L5HdZ",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pandas as pd"
+ ],
+ "metadata": {
+ "id": "qAYaAT_VQkD8"
+ },
+ "execution_count": 8,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "default = pd.read_csv('https://github.com/ybifoundation/Dataset/raw/main/Credit%20Default.csv')"
+ ],
+ "metadata": {
+ "id": "vQGxNI1yQic0"
+ },
+ "execution_count": 7,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "default.head()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "id": "ApSe_cPnQnWF",
+ "outputId": "12abd080-df2f-41f7-d293-03bb0b713fec"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Income Age Loan Loan to Income Default\n",
+ "0 66155.92510 59.017015 8106.532131 0.122537 0\n",
+ "1 34415.15397 48.117153 6564.745018 0.190752 0\n",
+ "2 57317.17006 63.108049 8020.953296 0.139940 0\n",
+ "3 42709.53420 45.751972 6103.642260 0.142911 0\n",
+ "4 66952.68885 18.584336 8770.099235 0.130990 1"
+ ],
+ "text/html": [
+ "\n",
+ " \n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Income | \n",
+ " Age | \n",
+ " Loan | \n",
+ " Loan to Income | \n",
+ " Default | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 66155.92510 | \n",
+ " 59.017015 | \n",
+ " 8106.532131 | \n",
+ " 0.122537 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 34415.15397 | \n",
+ " 48.117153 | \n",
+ " 6564.745018 | \n",
+ " 0.190752 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 57317.17006 | \n",
+ " 63.108049 | \n",
+ " 8020.953296 | \n",
+ " 0.139940 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 42709.53420 | \n",
+ " 45.751972 | \n",
+ " 6103.642260 | \n",
+ " 0.142911 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 66952.68885 | \n",
+ " 18.584336 | \n",
+ " 8770.099235 | \n",
+ " 0.130990 | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "default.info()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Y4rkuBHUQp1s",
+ "outputId": "20643ffc-eabd-4cf9-d9a2-c4f5452d71b6"
+ },
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "\n",
+ "RangeIndex: 2000 entries, 0 to 1999\n",
+ "Data columns (total 5 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 Income 2000 non-null float64\n",
+ " 1 Age 2000 non-null float64\n",
+ " 2 Loan 2000 non-null float64\n",
+ " 3 Loan to Income 2000 non-null float64\n",
+ " 4 Default 2000 non-null int64 \n",
+ "dtypes: float64(4), int64(1)\n",
+ "memory usage: 78.2 KB\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "default.describe()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 300
+ },
+ "id": "-g29qQCrQvEi",
+ "outputId": "cb03d571-8cec-436e-cdc3-2e7aa73ad3fb"
+ },
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " Income Age Loan Loan to Income Default\n",
+ "count 2000.000000 2000.000000 2000.000000 2000.000000 2000.000000\n",
+ "mean 45331.600018 40.927143 4444.369695 0.098403 0.141500\n",
+ "std 14326.327119 13.262450 3045.410024 0.057620 0.348624\n",
+ "min 20014.489470 18.055189 1.377630 0.000049 0.000000\n",
+ "25% 32796.459720 29.062492 1939.708847 0.047903 0.000000\n",
+ "50% 45789.117310 41.382673 3974.719418 0.099437 0.000000\n",
+ "75% 57791.281670 52.596993 6432.410625 0.147585 0.000000\n",
+ "max 69995.685580 63.971796 13766.051240 0.199938 1.000000"
+ ],
+ "text/html": [
+ "\n",
+ " \n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Income | \n",
+ " Age | \n",
+ " Loan | \n",
+ " Loan to Income | \n",
+ " Default | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " count | \n",
+ " 2000.000000 | \n",
+ " 2000.000000 | \n",
+ " 2000.000000 | \n",
+ " 2000.000000 | \n",
+ " 2000.000000 | \n",
+ "
\n",
+ " \n",
+ " mean | \n",
+ " 45331.600018 | \n",
+ " 40.927143 | \n",
+ " 4444.369695 | \n",
+ " 0.098403 | \n",
+ " 0.141500 | \n",
+ "
\n",
+ " \n",
+ " std | \n",
+ " 14326.327119 | \n",
+ " 13.262450 | \n",
+ " 3045.410024 | \n",
+ " 0.057620 | \n",
+ " 0.348624 | \n",
+ "
\n",
+ " \n",
+ " min | \n",
+ " 20014.489470 | \n",
+ " 18.055189 | \n",
+ " 1.377630 | \n",
+ " 0.000049 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 25% | \n",
+ " 32796.459720 | \n",
+ " 29.062492 | \n",
+ " 1939.708847 | \n",
+ " 0.047903 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 50% | \n",
+ " 45789.117310 | \n",
+ " 41.382673 | \n",
+ " 3974.719418 | \n",
+ " 0.099437 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " 75% | \n",
+ " 57791.281670 | \n",
+ " 52.596993 | \n",
+ " 6432.410625 | \n",
+ " 0.147585 | \n",
+ " 0.000000 | \n",
+ "
\n",
+ " \n",
+ " max | \n",
+ " 69995.685580 | \n",
+ " 63.971796 | \n",
+ " 13766.051240 | \n",
+ " 0.199938 | \n",
+ " 1.000000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "
\n"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 11
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "default.columns"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "F4Wr_SRFQyaY",
+ "outputId": "d2863923-02e5-40b0-8a81-eed00481a273"
+ },
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "Index(['Income', 'Age', 'Loan', 'Loan to Income', 'Default'], dtype='object')"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 12
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y = default['Default']\n",
+ "X = default.drop(['Default'],axis=1)"
+ ],
+ "metadata": {
+ "id": "hK7M3iqQQ3ds"
+ },
+ "execution_count": 14,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.model_selection import train_test_split\n",
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7, random_state=2529)"
+ ],
+ "metadata": {
+ "id": "M4li_JDkRC9G"
+ },
+ "execution_count": 16,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "print(\"Shape of X_train:\", X_train.shape)\n",
+ "print(\"Shape of X_test:\", X_test.shape)\n",
+ "print(\"Shape of y_train:\", y_train.shape)\n",
+ "print(\"Shape of y_test:\", y_test.shape)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "zUvlrHhPRK8h",
+ "outputId": "8c3a31b7-eaa5-44ac-9144-c72156848c0c"
+ },
+ "execution_count": 18,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Shape of X_train: (1400, 4)\n",
+ "Shape of X_test: (600, 4)\n",
+ "Shape of y_train: (1400,)\n",
+ "Shape of y_test: (600,)\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.linear_model import LogisticRegression\n",
+ "model = LogisticRegression()"
+ ],
+ "metadata": {
+ "id": "0IB3CjbDRQ3L"
+ },
+ "execution_count": 20,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.fit(X_train, y_train)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 75
+ },
+ "id": "qzUM38XoRWJ9",
+ "outputId": "d7d0bb6c-70a2-4514-9ab0-f7b2832d8183"
+ },
+ "execution_count": 22,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "LogisticRegression()"
+ ],
+ "text/html": [
+ "LogisticRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org. "
+ ]
+ },
+ "metadata": {},
+ "execution_count": 22
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.intercept_\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "cW123Z52Rago",
+ "outputId": "cf54cb26-b321-423a-c76c-17d0cdb126cf"
+ },
+ "execution_count": 23,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([9.39569095])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 23
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "model.coef_\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "wPOdXQbWRc2p",
+ "outputId": "5178fcaa-a9f2-49c6-8f94-8e713cc85747"
+ },
+ "execution_count": 24,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([[-2.31410016e-04, -3.43062682e-01, 1.67863323e-03,\n",
+ " 1.51188530e+00]])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 24
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y_pred = model.predict(X_test)"
+ ],
+ "metadata": {
+ "id": "IKLb8VHMRfqh"
+ },
+ "execution_count": 26,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "y_pred"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "6ERmV_-PRj7M",
+ "outputId": "85595e10-3099-4509-9fe6-1de40fa4cf58"
+ },
+ "execution_count": 27,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,\n",
+ " 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0,\n",
+ " 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,\n",
+ " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,\n",
+ " 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,\n",
+ " 0, 0, 0, 0, 0, 0])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 27
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.metrics import confusion_matrix, accuracy_score, classification_report\n",
+ "\n",
+ "model_accuracy = ..."
+ ],
+ "metadata": {
+ "id": "HE4RnQxJRnRg"
+ },
+ "execution_count": 29,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "confusion_matrix(y_test,y_pred)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e7vOwUMDRqE8",
+ "outputId": "6dba6108-09c1-438e-84a8-7e38783cae74"
+ },
+ "execution_count": 30,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([[506, 13],\n",
+ " [ 17, 64]])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 30
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "accuracy_score(y_test,y_pred)\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "_AxkiyGXRuHS",
+ "outputId": "1bbc0f1c-efa8-4798-d07c-2ee95faf7a38"
+ },
+ "execution_count": 31,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "0.95"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 31
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "print(classification_report(y_test,y_pred))\n"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "8xt9qfJYRwih",
+ "outputId": "c4cd69f2-badb-4124-cb1f-815150186aa4"
+ },
+ "execution_count": 32,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ " precision recall f1-score support\n",
+ "\n",
+ " 0 0.97 0.97 0.97 519\n",
+ " 1 0.83 0.79 0.81 81\n",
+ "\n",
+ " accuracy 0.95 600\n",
+ " macro avg 0.90 0.88 0.89 600\n",
+ "weighted avg 0.95 0.95 0.95 600\n",
+ "\n"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file