diff --git a/Kidney Stone Prediction/Dataset/README.md b/Kidney Stone Prediction/Dataset/README.md new file mode 100644 index 000000000..cbabdc231 --- /dev/null +++ b/Kidney Stone Prediction/Dataset/README.md @@ -0,0 +1 @@ +The dataset which is used here, is collected from Kaggle website. Here is the link of the dataset : https://www.kaggle.com/utkarshxy/kidney-stone-data. I have uploaded the same here, you can access that too! diff --git a/Kidney Stone Prediction/Dataset/kidney_stone_data.csv b/Kidney Stone Prediction/Dataset/kidney_stone_data.csv new file mode 100644 index 000000000..6406fcab1 --- /dev/null +++ b/Kidney Stone Prediction/Dataset/kidney_stone_data.csv @@ -0,0 +1,701 @@ +treatment,stone_size,success +B,large,1 +A,large,1 +A,large,0 +A,large,1 +A,large,1 +B,large,1 +A,small,1 +B,large,1 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +A,large,0 +B,large,0 +B,small,1 +A,large,0 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +A,small,1 +B,large,1 +A,large,1 +A,large,0 +A,small,1 +B,small,1 +A,large,0 +B,small,1 +A,small,1 +B,small,1 +B,small,1 +A,large,0 +B,small,1 +B,small,1 +B,small,1 +A,large,0 +A,large,1 +B,small,1 +A,small,1 +B,small,1 +A,large,0 +A,large,1 +A,large,0 +A,small,1 +B,small,1 +A,large,1 +B,small,0 +A,small,1 +A,small,1 +A,large,0 +B,small,1 +B,small,0 +B,small,1 +B,small,1 +B,large,1 +A,small,1 +A,small,1 +B,small,1 +A,large,1 +B,large,1 +A,large,1 +B,small,1 +B,large,1 +A,small,1 +A,large,1 +B,large,1 +A,small,1 +A,large,1 +B,large,0 +B,small,1 +A,small,1 +B,large,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +B,large,1 +B,large,1 +A,large,1 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +B,small,1 +A,large,1 +A,large,0 +B,small,1 +B,large,0 +A,large,1 +B,large,1 +A,small,1 +A,large,1 +A,large,0 +A,small,1 +B,large,0 +B,small,1 +A,small,1 +A,large,1 +A,large,1 +B,small,1 +B,large,1 +A,large,1 +A,large,1 +B,small,1 +B,large,1 +A,large,1 +B,small,1 +B,small,1 +B,small,0 +B,small,1 +B,large,0 +B,small,1 +B,small,1 +B,small,0 +A,large,0 +B,large,0 +A,small,1 +A,small,1 +A,large,0 +B,small,1 +A,large,1 +A,large,0 +B,small,1 +B,small,1 +A,large,1 +A,small,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +A,small,1 +A,large,1 +A,large,0 +A,large,0 +B,small,1 +B,small,1 +A,large,1 +A,large,0 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +B,large,0 +B,small,1 +A,large,1 +A,small,1 +A,large,1 +A,large,1 +B,large,1 +B,small,1 +B,small,1 +B,large,0 +A,large,1 +B,small,0 +A,large,1 +A,large,0 +B,small,1 +B,small,1 +A,large,0 +A,small,1 +B,large,0 +B,small,1 +A,large,1 +A,large,1 +B,small,0 +A,large,0 +A,large,0 +B,small,1 +B,small,1 +A,large,1 +A,large,1 +A,small,1 +B,small,0 +B,large,1 +A,large,1 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +A,large,1 +A,large,1 +A,large,0 +A,large,0 +A,large,1 +A,large,1 +A,large,1 +B,large,1 +B,small,1 +B,small,1 +A,large,1 +A,large,0 +A,large,1 +A,large,1 +A,large,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +B,small,1 +A,large,1 +B,small,0 +A,large,1 +B,small,1 +A,large,0 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +B,large,0 +A,small,1 +B,small,1 +B,large,1 +A,large,1 +A,small,1 +A,large,1 +B,large,0 +A,large,0 +A,large,0 +B,small,1 +B,small,0 +A,small,1 +A,large,0 +A,small,1 +A,large,1 +B,large,1 +A,large,1 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +A,small,1 +B,small,1 +B,small,1 +B,large,1 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +A,small,1 +A,small,0 +B,small,1 +A,small,1 +B,large,1 +A,large,1 +B,small,1 +A,large,1 +A,large,1 +A,large,0 +B,large,0 +B,small,1 +A,large,1 +B,large,1 +A,large,1 +A,large,1 +A,large,1 +B,small,1 +A,large,1 +A,large,0 +B,small,1 +A,large,1 +A,large,1 +A,large,1 +A,small,1 +B,small,1 +B,large,1 +A,small,1 +A,large,0 +A,large,1 +A,small,1 +B,small,1 +B,small,0 +A,small,1 +A,small,1 +A,large,0 +B,small,1 +B,large,1 +A,large,0 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +A,large,0 +A,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +B,small,1 +A,large,1 +B,small,0 +A,small,1 +B,small,0 +B,large,1 +A,large,0 +B,large,1 +B,large,1 +B,large,1 +B,large,1 +B,small,1 +B,small,1 +B,small,1 +A,large,0 +B,small,1 +A,large,1 +B,large,1 +B,large,1 +B,small,0 +B,small,1 +B,small,1 +A,large,0 +A,large,1 +A,large,1 +A,small,1 +A,large,1 +B,small,1 +A,small,1 +B,small,1 +B,small,1 +B,small,1 +B,large,1 +A,large,1 +B,large,1 +B,small,1 +B,large,0 +A,large,1 +A,small,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +A,small,1 +A,large,1 +B,small,0 +B,small,1 +A,small,1 +A,large,1 +A,large,1 +B,small,1 +B,large,1 +A,large,1 +A,small,0 +A,large,1 +B,large,0 +B,small,1 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +B,small,1 +B,small,0 +B,small,1 +A,large,1 +A,large,0 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +A,small,1 +A,small,1 +B,large,1 +A,large,1 +B,small,1 +A,large,0 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,large,1 +B,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +A,large,1 +A,large,1 +B,large,1 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +A,large,0 +A,large,0 +A,large,1 +A,large,1 +A,large,0 +A,large,1 +A,large,0 +B,small,1 +A,large,1 +B,small,1 +A,large,0 +A,large,1 +B,small,1 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +A,large,0 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +A,large,1 +B,large,1 +B,large,1 +A,small,1 +B,small,0 +B,small,1 +B,small,0 +A,large,1 +B,small,1 +A,large,0 +B,small,1 +A,large,0 +B,large,0 +A,large,1 +A,large,1 +A,large,1 +A,large,1 +A,large,1 +B,large,1 +B,small,0 +A,large,0 +B,small,1 +B,large,1 +B,large,1 +B,small,1 +B,small,0 +B,small,1 +B,small,1 +B,small,1 +A,large,0 +A,large,0 +A,large,0 +B,large,1 +B,small,1 +A,large,1 +B,small,1 +A,large,0 +A,large,1 +A,large,1 +A,large,1 +A,large,0 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +B,small,1 +B,small,0 +A,large,0 +A,large,1 +B,small,0 +A,large,1 +B,large,1 +B,small,1 +B,small,1 +A,small,1 +B,large,0 +B,small,1 +B,small,1 +B,large,0 +A,large,1 +A,large,1 +A,small,1 +A,large,0 +B,small,1 +A,large,1 +B,small,1 +A,large,0 +B,large,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,1 +A,large,0 +A,small,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +A,small,0 +A,large,1 +A,large,1 +B,large,1 +A,large,1 +A,small,1 +B,large,0 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +A,small,1 +A,large,1 +A,small,1 +A,large,1 +A,small,1 +A,large,0 +A,small,1 +B,small,1 +B,small,1 +A,small,1 +B,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,0 +A,large,0 +A,large,1 +A,small,1 +A,large,1 +B,small,1 +A,small,0 +A,small,1 +B,large,1 +A,large,1 +B,small,1 +B,small,1 +A,large,0 +A,large,1 +A,large,1 +B,large,0 +B,small,1 +A,large,1 +A,large,1 +B,large,0 +A,large,1 +B,small,1 +B,large,0 +A,small,1 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +B,large,1 +B,small,1 +A,large,1 +A,large,1 +A,large,1 +A,large,1 +A,large,1 +B,small,0 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +A,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +A,large,0 +A,small,0 +B,small,1 +A,large,0 +A,small,1 +A,large,0 +A,large,1 +A,large,1 +B,large,1 +B,small,0 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,small,0 +B,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +A,large,1 +B,small,1 +B,large,1 +A,small,1 +A,large,1 +A,large,1 +A,large,0 +B,large,0 +B,small,1 +B,large,1 +B,large,0 +B,large,1 +A,large,0 +A,small,0 +A,large,1 +A,large,1 +B,small,0 +B,small,0 +B,large,1 +A,large,1 +B,large,0 +A,large,0 +A,large,1 +B,large,1 +B,small,1 +A,large,0 +B,small,1 +B,small,1 +B,small,1 +A,small,1 +B,small,1 +B,small,1 +B,small,1 +A,large,0 +B,small,1 +B,small,1 +B,small,1 +A,large,1 +B,small,0 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +B,small,1 +B,small,1 +B,small,0 +A,large,1 +A,large,1 +A,large,0 +B,large,1 +A,large,1 +B,small,0 +B,small,0 +B,small,1 +A,large,1 +A,large,1 +B,small,1 +B,small,1 +B,small,0 +A,large,1 +A,large,0 +A,large,1 +A,large,1 +A,small,1 +B,small,0 +B,small,1 +B,small,1 +A,large,1 +B,small,1 +B,small,0 +A,large,1 +A,large,1 +B,small,1 +B,small,0 +B,small,1 +B,small,1 +A,small,1 +A,large,1 +A,large,1 +B,large,0 +B,small,0 +B,small,1 +B,small,1 +A,large,1 +A,small,1 diff --git a/Kidney Stone Prediction/Images/kid1.jpg b/Kidney Stone Prediction/Images/kid1.jpg new file mode 100644 index 000000000..2769cdf08 Binary files /dev/null and b/Kidney Stone Prediction/Images/kid1.jpg differ diff --git a/Kidney Stone Prediction/Images/kid2.png b/Kidney Stone Prediction/Images/kid2.png new file mode 100644 index 000000000..1a10419ba Binary files /dev/null and b/Kidney Stone Prediction/Images/kid2.png differ diff --git a/Kidney Stone Prediction/Model/Kidney_Stone_Prediction.ipynb b/Kidney Stone Prediction/Model/Kidney_Stone_Prediction.ipynb new file mode 100644 index 000000000..b6d31f9b1 --- /dev/null +++ b/Kidney Stone Prediction/Model/Kidney_Stone_Prediction.ipynb @@ -0,0 +1,1610 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Kidney Stone Prediction\n", + "\n", + "![](https://wallpaperaccess.com/full/5793661.jpg)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Contents\n", + "1. Abstract\n", + "2. Dataset\n", + "3. Goal\n", + "4. Importing libraries and Dataset\n", + "5. Data Cleaning\n", + "6. Data Visualization\n", + "7. Prediction Models\n", + " - KNN Algorithm\n", + " - Logistic Regression\n", + " - Random Forest Classifier\n", + " - Decision Tree Classifier\n", + " - Support Vector Machine Classifier\n", + " - AdaBoost Classifier\n", + " - Gradient Boosting Classifier\n", + " - Gaussian Naive Bayes Classifier\n", + " - MLP Classifier\n", + "8. Model comparison\n", + "9. Conclusion\n", + "\n", + "********************" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Abstract\n", + "A small, hard deposit that forms in the kidneys and is often painful when passed.\n", + "\n", + "Kidney stones are hard deposits of minerals and acid salts that stick together in concentrated urine. They can be painful when passing through the urinary tract, but usually don't cause permanent damage.\n", + "\n", + "The most common symptom is severe pain, usually in the side of the abdomen, that's often associated with nausea.\n", + "Treatment includes pain relievers and drinking lots of water to help pass the stone. Medical procedures may be required to remove or break up larger stones.\n", + "\n", + "The most common symptom is severe pain, usually in the side of the abdomen, that's often associated with nausea.\n", + "\n", + "Treatment includes pain relievers and drinking lots of water to help pass the stone. Medical procedures may be required to remove or break up larger stones.\n", + "\n", + "\n", + "### Dataset\n", + "The dataset which is used here, is collected from Kaggle website. Here is the link of the dataset : https://www.kaggle.com/utkarshxy/kidney-stone-data.\n", + "\n", + "### Goal\n", + "The goal of this project is to create a prediction model which will predict the success rate of kidney stone operation based on the stone's size and type of treatment.\n", + "************************************************************" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Importing all the required libraries and Dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", + "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", + "execution": { + "iopub.execute_input": "2021-02-27T08:07:10.032292Z", + "iopub.status.busy": "2021-02-27T08:07:10.031675Z", + "iopub.status.idle": "2021-02-27T08:07:11.397239Z", + "shell.execute_reply": "2021-02-27T08:07:11.396432Z" + }, + "papermill": { + "duration": 1.379825, + "end_time": "2021-02-27T08:07:11.397439", + "exception": false, + "start_time": "2021-02-27T08:07:10.017614", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "#Import Library Files\n", + "\n", + "import pandas as pd\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LogisticRegression\n", + "from sklearn.neighbors import KNeighborsClassifier\n", + "from sklearn.metrics import roc_curve\n", + "from sklearn.ensemble import AdaBoostClassifier, GradientBoostingClassifier\n", + "from sklearn.neural_network import MLPClassifier" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.418498Z", + "iopub.status.busy": "2021-02-27T08:07:11.417905Z", + "iopub.status.idle": "2021-02-27T08:07:11.470784Z", + "shell.execute_reply": "2021-02-27T08:07:11.471194Z" + }, + "papermill": { + "duration": 0.065289, + "end_time": "2021-02-27T08:07:11.471372", + "exception": false, + "start_time": "2021-02-27T08:07:11.406083", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
treatmentstone_sizesuccess
0Blarge1
1Alarge1
2Alarge0
3Alarge1
4Alarge1
\n", + "
" + ], + "text/plain": [ + " treatment stone_size success\n", + "0 B large 1\n", + "1 A large 1\n", + "2 A large 0\n", + "3 A large 1\n", + "4 A large 1" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Read CSV File\n", + "\n", + "data = pd.read_csv('kidney_stone_data.csv')\n", + "\n", + "data.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.504485Z", + "iopub.status.busy": "2021-02-27T08:07:11.503835Z", + "iopub.status.idle": "2021-02-27T08:07:11.508313Z", + "shell.execute_reply": "2021-02-27T08:07:11.507816Z" + }, + "papermill": { + "duration": 0.028853, + "end_time": "2021-02-27T08:07:11.508460", + "exception": false, + "start_time": "2021-02-27T08:07:11.479607", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 700 entries, 0 to 699\n", + "Data columns (total 3 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 treatment 700 non-null object\n", + " 1 stone_size 700 non-null object\n", + " 2 success 700 non-null int64 \n", + "dtypes: int64(1), object(2)\n", + "memory usage: 16.5+ KB\n" + ] + } + ], + "source": [ + "data.info()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "papermill": { + "duration": 0.008718, + "end_time": "2021-02-27T08:07:11.525762", + "exception": false, + "start_time": "2021-02-27T08:07:11.517044", + "status": "completed" + }, + "tags": [] + }, + "source": [ + "### Cleaning Data" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.545834Z", + "iopub.status.busy": "2021-02-27T08:07:11.544975Z", + "iopub.status.idle": "2021-02-27T08:07:11.552100Z", + "shell.execute_reply": "2021-02-27T08:07:11.552503Z" + }, + "papermill": { + "duration": 0.018632, + "end_time": "2021-02-27T08:07:11.552699", + "exception": false, + "start_time": "2021-02-27T08:07:11.534067", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "treatment 0\n", + "stone_size 0\n", + "success 0\n", + "dtype: int64" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Check null value\n", + "data.isna().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.573186Z", + "iopub.status.busy": "2021-02-27T08:07:11.572313Z", + "iopub.status.idle": "2021-02-27T08:07:11.578950Z", + "shell.execute_reply": "2021-02-27T08:07:11.578265Z" + }, + "papermill": { + "duration": 0.017914, + "end_time": "2021-02-27T08:07:11.579098", + "exception": false, + "start_time": "2021-02-27T08:07:11.561184", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(700, 3)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Data Visualization" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.607827Z", + "iopub.status.busy": "2021-02-27T08:07:11.604477Z", + "iopub.status.idle": "2021-02-27T08:07:11.740062Z", + "shell.execute_reply": "2021-02-27T08:07:11.739453Z" + }, + "papermill": { + "duration": 0.152112, + "end_time": "2021-02-27T08:07:11.740196", + "exception": false, + "start_time": "2021-02-27T08:07:11.588084", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAPWklEQVR4nO3df6zdd13H8edrLW7ID2nTu1n6g1ZtjJ3AkOskEBUZsvJDujCHxUwbaVI1EyExSosR/JEqBDRMZH9UGRT5MRtgrmLimMW5GJHSwmRrx1xD53bT0paBDCJOW97+cb/9cNre252t+95z2/t8JDfnnM/5fr/3XTL67Pece743VYUkSQAXjHoASdLsYRQkSY1RkCQ1RkGS1BgFSVIzf9QDnI1FixbVihUrRj2GJJ1T9uzZ89WqGpvquXM6CitWrGD37t2jHkOSzilJ/nO653z5SJLUGAVJUmMUJEmNUZAkNUZBktQYBUlSYxQkSY1RkCQ1RkGS1JzTn2iWzmcP/OGzRz2CZqHlb72r1+N7piBJaoyCJKkxCpKkxihIkhqjIElqjIIkqTEKkqTGKEiSGqMgSWqMgiSpMQqSpMYoSJIaoyBJaoyCJKkxCpKkxihIkhqjIElqjIIkqek1CknuT3JXkjuT7O7WFia5Lcl93e2Cge03J9mf5N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4R+DXg+qr6cHeZkXnAK6aYQZoRnilIJ7sLeGmSdyT5yar6xhm2fSmTv6AIgKr6OvAC4I6qOtCtnfhdAC8DNiW5E7gduAhYzuQlHN6S5M3As6rq249xBukJZRSkAVX1H8DzmfyL+U+SvBU4xnf/v3LRwObh9MuMT7V2Yv3qqrqs+1peVfdU1UeAVwPfBm5N8pJpZpBmhFGQBiR5JvDfVfUh4F3AjwH3M/mXNMDVA5t/ismLCZ7YdwGT//L/6SQru7UTLx/dCrwhSbr153W3PwB8uar+nMmr0z5nmhmkGeEF8aQBSa4E3gl8B/g/4NeBJwPvAw4DnwXGq+rFSZ7K5MtHzweOA39QVZ9I8nLgj5n8R9eRqvrZJE8G3g28kMmzhvur6lVJNgPXdt/rK8AvAj9+6gxVtXsm/vySUZAkNb58JElqjIIkqTEKkqTGKEiSGqMgSWqMgiSpMQqSpOb/AdvY3FRZaU+PAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "#Check sucess rate\n", + "\n", + "sns.countplot(x=kidney_stone['success'])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "****************************\n", + "## Prediction Models\n", + "A classification model tries to draw some conclusion from the input values given for training. It will predict the class labels/categories for the new data.\n", + "\n", + "Here we are going to prepare several Classification machine learning models based on those we will do a comparative analysis that which model is better among them.\n", + "\n", + "We are using nine different classification algorithms -\n", + "* **K-Nearest Neighbours Algorithm** : K-Nearest Neighbour is one of the simplest Machine Learning algorithms based on Supervised Learning technique. K-NN algorithm assumes the similarity between the new case/data and available cases and put the new case into the category that is most similar to the available categories. K-NN algorithm stores all the available data and classifies a new data point based on the similarity. This means when new data appears then it can be easily classified into a well suite category by using K- NN algorithm.\n", + "\n", + "\n", + "* **Support Vector Machine Algorithm** : Support Vector Machine or SVM is one of the most popular Supervised Learning algorithms, which is used for Classification as well as Regression problems. However, primarily, it is used for Classification problems in Machine Learning. The goal of the SVM algorithm is to create the best line or decision boundary that can segregate n-dimensional space into classes so that we can easily put the new data point in the correct category in the future. This best decision boundary is called a hyperplane.\n", + "\n", + "\n", + "* **Random Forest Classifier** : Random Forest is a popular machine learning algorithm that belongs to the supervised learning technique. It can be used for both Classification and Regression problems in ML. It is based on the concept of ensemble learning, which is a process of combining multiple classifiers to solve a complex problem and to improve the performance of the model.\n", + "\n", + "\n", + "* **Logistic Regression** : Logistic regression is a statistical model that in its basic form uses a logistic function to model a binary dependent variable, although many more complex extensions exist. In regression analysis, logistic regression (or logit regression) is estimating the parameters of a logistic model (a form of binary regression).\n", + "\n", + "\n", + "* **Naive Bayes Classifcation Algorithm** : Naive Bayes classifiers are a family of simple \"probabilistic classifiers\" based on applying Bayes' theorem with strong independence assumptions between the features. They are among the simplest Bayesian network models, but coupled with kernel density estimation, they can achieve higher accuracy levels.\n", + "\n", + "\n", + "* **Decision Tree Classifier** : Decision Tree is a Supervised learning technique that can be used for both classification and Regression problems, but mostly it is preferred for solving Classification problems. It is a tree-structured classifier, where internal nodes represent the features of a dataset, branches represent the decision rules and each leaf node represents the outcome.\n", + "\n", + "\n", + "* **Gradient Boosting Algorithm** : Gradient boosting is a machine learning technique for regression, classification and other tasks, which produces a prediction model in the form of an ensemble of weak prediction models, typically decision trees.\n", + "\n", + "\n", + "* **AdaBoosting Algorithm** : AdaBoost, short for Adaptive Boosting, is a statistical classification meta-algorithm formulated by Yoav Freund and Robert Schapire, who won the 2003 Gödel Prize for their work. It can be used in conjunction with many other types of learning algorithms to improve performance.\n", + "\n", + "\n", + "* **Artificial Neural Network** : Artificial neural networks, usually simply called neural networks, are computing systems vaguely inspired by the biological neural networks that constitute animal brains. An ANN is based on a collection of connected units or nodes called artificial neurons, which loosely model the neurons in a biological brain.\n", + "\n", + "Let's quickly get into the algorithms!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Splitting the dataset\n", + "* creating the training and testing dataset by spliting at 90:10 ratio\n", + "* training sets are x_train and y_train\n", + "* testing sets are x_test and y_test" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.789096Z", + "iopub.status.busy": "2021-02-27T08:07:11.788157Z", + "iopub.status.idle": "2021-02-27T08:07:11.798610Z", + "shell.execute_reply": "2021-02-27T08:07:11.798080Z" + }, + "papermill": { + "duration": 0.02923, + "end_time": "2021-02-27T08:07:11.798753", + "exception": false, + "start_time": "2021-02-27T08:07:11.769523", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(630, 4)" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x= data[['treatment','stone_size']]\n", + "y = data['success']\n", + "\n", + "x_dummies = pd.get_dummies(x) #Change String to Numerical \n", + "\n", + "x_train, x_test, y_train, y_test = train_test_split(x_dummies,y, test_size=0.10, random_state=0)\n", + "x_train.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Logistic Regression\n", + " Logistic regression is a statistical model that in its basic form uses a logistic function to model a binary dependent variable, although many more complex extensions exist. In regression analysis, logistic regression (or logit regression) is estimating the parameters of a logistic model (a form of binary regression)." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.826623Z", + "iopub.status.busy": "2021-02-27T08:07:11.825697Z", + "iopub.status.idle": "2021-02-27T08:07:11.842287Z", + "shell.execute_reply": "2021-02-27T08:07:11.841677Z" + }, + "papermill": { + "duration": 0.033378, + "end_time": "2021-02-27T08:07:11.842422", + "exception": false, + "start_time": "2021-02-27T08:07:11.809044", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "LogisticRegression()" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Create a model\n", + "\n", + "logreg = LogisticRegression()\n", + "\n", + "logreg.fit(x_train,y_train)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.871512Z", + "iopub.status.busy": "2021-02-27T08:07:11.870505Z", + "iopub.status.idle": "2021-02-27T08:07:11.875217Z", + "shell.execute_reply": "2021-02-27T08:07:11.874742Z" + }, + "papermill": { + "duration": 0.022217, + "end_time": "2021-02-27T08:07:11.875348", + "exception": false, + "start_time": "2021-02-27T08:07:11.853131", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = logreg.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.907719Z", + "iopub.status.busy": "2021-02-27T08:07:11.906743Z", + "iopub.status.idle": "2021-02-27T08:07:11.911100Z", + "shell.execute_reply": "2021-02-27T08:07:11.911489Z" + }, + "papermill": { + "duration": 0.024309, + "end_time": "2021-02-27T08:07:11.911675", + "exception": false, + "start_time": "2021-02-27T08:07:11.887366", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Create Confusion Matrix\n", + "\n", + "from sklearn import metrics\n", + "\n", + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:11.983425Z", + "iopub.status.busy": "2021-02-27T08:07:11.966288Z", + "iopub.status.idle": "2021-02-27T08:07:12.111234Z", + "shell.execute_reply": "2021-02-27T08:07:12.110749Z" + }, + "papermill": { + "duration": 0.188508, + "end_time": "2021-02-27T08:07:12.111377", + "exception": false, + "start_time": "2021-02-27T08:07:11.922869", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVoAAAD4CAYAAACt8i4nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAQe0lEQVR4nO3dfZBddX3H8fd3l6QqLYJAICSpwSG10DqaTkhRtOVBHsSH0JHgUzW1ma7jIIZqFUSrg9URH0AB0XFHkEyVh9SWSUSrYISio4UESAUSIfJQ2GRLpgpTBZXs3W//2Etck2Xv3XB/99w9eb8yZ/bec+/93W/IzofffM/vnBOZiSSpnL6qC5CkujNoJakwg1aSCjNoJakwg1aSCtur+BfMnOOyBu3i1QcvrLoE9aDVD10Xz3SM7f97f9uZM+OAFzzj72uHM1pJKqz4jFaSumq0UXUFuzBoJdVLY6TqCnZh0EqqlczRqkvYhUErqV5GDVpJKssZrSQV5sEwSSrMGa0klZWuOpCkwjwYJkmF2TqQpMI8GCZJhTmjlaTCPBgmSYV5MEySysq0RytJZdmjlaTCbB1IUmHOaCWpsMb2qivYhUErqV5sHUhSYbYOJKkwZ7SSVJhBK0llpQfDJKkwe7SSVFgHWwcR8SDwC6ABjGTmooh4HnANMB94EDg9Mx+dbJy+jlUk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svculGjQSqoVe7SSVJg9WkkqzB6tJBU2autAkspyRitJhbnqQJIKs3UgSYXZOpCkwpzRSlJhzmglqbBGNqouYRcGraRa8RRcSSrMU3AlqTBntJJUmKsOJKkwVx1IUmGegitJhdmjlaTC7NFKUmHOaCWpMNfRSlJhzmglqTBXHUhSYR4Mk6TCerF10Fd1AZLUSTmFP61ExMkRcU9E/DQiztndmpzRSqqVTs1oI6IfuBQ4ARgC1kXEmszcONWxDFpJtdLBHu1i4KeZeT9ARFwNLAF6L2hHntwSpb9juoiIgcwcrLoO9RZ/LzprKpkTEQPAwLhdg+P+LeYAD497bQj4892pyR5tdw20fov2QP5eVCQzBzNz0bht/P/wJgrs3ZouG7SSNLEhYN6453OBrbszkEErSRNbByyIiEMjYibwRmDN7gzkwbDusg+nifh70YMycyQi3gV8B+gHLs/Mu3dnrOjFxb2SVCe2DiSpMINWkgozaLukU6fyqT4i4vKI2BYRd1Vdi8oyaLtg3Kl8rwKOAN4UEUdUW5V6wBXAyVUXofIM2u7YcSpfZj4JPHUqn/ZgmXkz8POq61B5Bm13THQq35yKapHUZQZtd3TsVD5J049B2x0dO5VP0vRj0HZHx07lkzT9GLRdkJkjwFOn8m0CVu3uqXyqj4i4CvgR8MKIGIqI5VXXpDI8BVeSCnNGK0mFGbSSVJhBK0mFGbSSVJhBK0mFGbSSVJhBK0mF/T/4t7z505gJSgAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "#Visualize Confusion Matrix\n", + "\n", + "sns.heatmap(cnf_matrix, annot=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:12.142927Z", + "iopub.status.busy": "2021-02-27T08:07:12.142198Z", + "iopub.status.idle": "2021-02-27T08:07:12.151815Z", + "shell.execute_reply": "2021-02-27T08:07:12.151317Z" + }, + "papermill": { + "duration": 0.028431, + "end_time": "2021-02-27T08:07:12.151953", + "exception": false, + "start_time": "2021-02-27T08:07:12.123522", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "#Check Model Accurancy\n", + "\n", + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-27T08:07:12.184425Z", + "iopub.status.busy": "2021-02-27T08:07:12.183706Z", + "iopub.status.idle": "2021-02-27T08:07:12.316789Z", + "shell.execute_reply": "2021-02-27T08:07:12.316142Z" + }, + "papermill": { + "duration": 0.152666, + "end_time": "2021-02-27T08:07:12.316943", + "exception": false, + "start_time": "2021-02-27T08:07:12.164277", + "status": "completed" + }, + "tags": [] + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXxU5fn//9cNISBbkCUsCRBWSVgCJqwuUBcEK1AsVGxVQBSXYi21rVpr8aP2p1Wrrf7cqFIILqCIiNsHPypUlC1hkX0nIQFkC4GQkP36/pGYhhCSASaZzOT9fDzyIDNz58x1ZzJvTs65cy5nZoiIiP+r5esCRETEOxToIiIBQoEuIhIgFOgiIgFCgS4iEiCCfPXEzZs3t4iICF89vYiIX1q9evURM2tR1mM+C/SIiAgSEhJ89fQiIn7JOZd0tsd0yEVEJEAo0EVEAoQCXUQkQCjQRUQChA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Q71Nd1V8GcpwP3FH0eBST6uu4LnPOVwKXAxrM8fj3wOYUd3wYAKy/0OavzHno/YKeZ7TazHGAOMKrUmFHArKLP5wFXO+fKaofnLyqcs5ktNrPMopsrKOwg5c88eZ0BngCeAQLhmryezPlO4GUzOwZgZoequEZv82TOBjQu+jyEMzuj+RUz+4byO7eNAuKs0AqgiXOu9YU8Z3UO9DAgucTtlKL7yhxjhY04jgPNqqS6yuHJnEuaROH/8P6swjk75/oAbc3sk6osrBJ58jp3Bbo6575zzq1wzg2rsuoqhydzfgy4xTmXAnwG3Fc1pfnMub7fK1Sdr4futebUfsTj+TjnbgFigcGVWlHlK3fOzrlawAvAhKoqqAp48joHUXjYZQiFv4Utdc71MLO0Sq6tsngy55uBmWb2d+fcQGB20ZwLKr88n/B6flXnPfSa2JzakznjnLsGeAQYaWbZVVRbZalozo2AHsAS51wihccaF/r5iVFPf7Y/MrNcM9sDbKMw4P2VJ3OeBLwHYGbLgXoUXsQqUHn0fj8X1TnQa2Jz6grnXHT44XUKw9zfj6tCBXM2s+Nm1tzMIswsgsLzBiPNzJ/7F3rys72AwhPgOOeaU3gIZneVVuldnsx5L3A1gHMuksJAP1ylVVathcBtRatdBgDHzezABW3R12eCKzhLfD2wncKz448U3fc4hW9oKHzB3wd2AquAjr6uuQrm/CVwEFhX9LHQ1zVX9pxLjV2Cn69y8fB1dsDzwGZgAzDO1zVXwZyjgO8oXAGzDhjq65ovcL7vAgeAXAr3xicBdwN3l3iNXy76fmzwxs+1/vRfRCRAVOdDLiIicg4U6CIiAUKBLiISIBToIiIBQoEuIhIgFOgiIgFCgS4iEiD+H08cGW+7Y5f+AAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "y_pred_proba = logreg.predict_proba(x_test)[::,1]\n", + "fpr, tpr, _ = metrics.roc_curve(y_test, y_pred_proba)\n", + "auc = metrics.roc_auc_score(y_test, y_pred_proba)\n", + "plt.plot(fpr,tpr,label=\"data 1, auc=\"+str(auc))\n", + "plt.legend(loc=4)\n", + "plt.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### K-Nearest Neighbour Algorithm\n", + "K-Nearest Neighbour is one of the simplest Machine Learning algorithms based on Supervised Learning technique. K-NN algorithm assumes the similarity between the new case/data and available cases and put the new case into the category that is most similar to the available categories. K-NN algorithm stores all the available data and classifies a new data point based on the similarity. This means when new data appears then it can be easily classified into a well suite category by using K- NN algorithm." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "KNeighborsClassifier(n_neighbors=6)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k=6\n", + "knn = KNeighborsClassifier(n_neighbors = k)\n", + "knn.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = knn.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVoAAAD4CAYAAACt8i4nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAQe0lEQVR4nO3dfZBddX3H8fd3l6QqLYJAICSpwSG10DqaTkhRtOVBHsSH0JHgUzW1ma7jIIZqFUSrg9URH0AB0XFHkEyVh9SWSUSrYISio4UESAUSIfJQ2GRLpgpTBZXs3W//2Etck2Xv3XB/99w9eb8yZ/bec+/93W/IzofffM/vnBOZiSSpnL6qC5CkujNoJakwg1aSCjNoJakwg1aSCtur+BfMnOOyBu3i1QcvrLoE9aDVD10Xz3SM7f97f9uZM+OAFzzj72uHM1pJKqz4jFaSumq0UXUFuzBoJdVLY6TqCnZh0EqqlczRqkvYhUErqV5GDVpJKssZrSQV5sEwSSrMGa0klZWuOpCkwjwYJkmF2TqQpMI8GCZJhTmjlaTCPBgmSYV5MEySysq0RytJZdmjlaTCbB1IUmHOaCWpsMb2qivYhUErqV5sHUhSYbYOJKkwZ7SSVJhBK0llpQfDJKkwe7SSVFgHWwcR8SDwC6ABjGTmooh4HnANMB94EDg9Mx+dbJy+jlUkSb0gR9v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oVe7SSVJg9WkkqzB6tJBU2autAkspyRitJhbnqQJIKs3UgSYXZOpCkwpzRSlJhzmglqbBGNqouYRcGraRa8RRcSSrMU3AlqTBntJJUmKsOJKkwVx1IUmGegitJhdmjlaTC7NFKUmHOaCWpMNfRSlJhzmglqTBXHUhSYR4Mk6TCerF10Fd1AZLUSTmFP61ExMkRcU9E/DQiztndmpzRSqqVTs1oI6IfuBQ4ARgC1kXEmszcONWxDFpJtdLBHu1i4KeZeT9ARFwNLAF6L2hHntwSpb9juoiIgcwcrLoO9RZ/LzprKpkTEQPAwLhdg+P+LeYAD497bQj4892pyR5tdw20fov2QP5eVCQzBzNz0bht/P/wJgrs3ZouG7SSNLEhYN6453OBrbszkEErSRNbByyIiEMjYibwRmDN7gzkwbDusg+nifh70YMycyQi3gV8B+gHLs/Mu3dnrOjFxb2SVCe2DiSpMINWkgozaLukU6fyqT4i4vKI2BYRd1Vdi8oyaLtg3Kl8rwKOAN4UEUdUW5V6wBXAyVUXofIM2u7YcSpfZj4JPHUqn/ZgmXkz8POq61B5Bm13THQq35yKapHUZQZtd3TsVD5J049B2x0dO5VP0vRj0HZHx07lkzT9GLRdkJkjwFOn8m0CVu3uqXyqj4i4CvgR8MKIGIqI5VXXpDI8BVeSCnNGK0mFGbSSVJhBK0mFGbSSVJhBK0mFGbSSVJhBK0mF/T/4t7z505gJSgAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "sns.heatmap(cnf_matrix, annot=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Decision Tree Classifier\n", + "Decision Tree is a Supervised learning technique that can be used for both classification and Regression problems, but mostly it is preferred for solving Classification problems. It is a tree-structured classifier, where internal nodes represent the features of a dataset, branches represent the decision rules and each leaf node represents the outcome." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "DecisionTreeClassifier()" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.tree import DecisionTreeClassifier\n", + "dtc=DecisionTreeClassifier()\n", + "dtc.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = dtc.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Random Forest Classifier\n", + "Random Forest is a popular machine learning algorithm that belongs to the supervised learning technique. It can be used for both Classification and Regression problems in ML. It is based on the concept of ensemble learning, which is a process of combining multiple classifiers to solve a complex problem and to improve the performance of the model." + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "RandomForestClassifier(n_estimators=225, random_state=1)" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.ensemble import RandomForestClassifier\n", + "rfc=RandomForestClassifier(n_estimators=225,random_state=1)\n", + "rfc.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = rfc.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Gausian Naive Bayes Classifier Algorithm\n", + "Naive Bayes classifiers are a family of simple \"probabilistic classifiers\" based on applying Bayes' theorem with strong independence assumptions between the features. They are among the simplest Bayesian network models, but coupled with kernel density estimation, they can achieve higher accuracy levels." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "GaussianNB()" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.naive_bayes import GaussianNB\n", + "nb=GaussianNB()\n", + "nb.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = nb.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### SVM Classification\n", + "Support Vector Machine or SVM is one of the most popular Supervised Learning algorithms, which is used for Classification as well as Regression problems. However, primarily, it is used for Classification problems in Machine Learning. The goal of the SVM algorithm is to create the best line or decision boundary that can segregate n-dimensional space into classes so that we can easily put the new data point in the correct category in the future. This best decision boundary is called a hyperplane." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "SVC(random_state=1)" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sklearn.svm import SVC\n", + "svc=SVC(random_state=1)\n", + "svc.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = svc.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Gradient Boosting Algorithm\n", + "Gradient boosting is a machine learning technique for regression, classification and other tasks, which produces a prediction model in the form of an ensemble of weak prediction models, typically decision trees." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [], + "source": [ + "gfc=GradientBoostingClassifier(n_estimators= 1000, max_leaf_nodes= 4, max_depth=None,random_state= 2,min_samples_split= 5)\n", + "gfc.fit(x_train,y_train)\n", + "y_head=gfc.predict(x_test)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = gfc.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### AdaBoost Algorithm\n", + "AdaBoost, short for Adaptive Boosting, is a statistical classification meta-algorithm formulated by Yoav Freund and Robert Schapire, who won the 2003 Gödel Prize for their work. It can be used in conjunction with many other types of learning algorithms to improve performance." + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "AdaBoostClassifier(n_estimators=100, random_state=0)" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "abc=AdaBoostClassifier(n_estimators=100, random_state=0)\n", + "abc.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = abc.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Artificial Neural Networks Algorithm\n", + "Artificial neural networks, usually simply called neural networks, are computing systems vaguely inspired by the biological neural networks that constitute animal brains. An ANN is based on a collection of connected units or nodes called artificial neurons, which loosely model the neurons in a biological brain." + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "MLPClassifier(alpha=1, max_iter=1000)" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ysa=MLPClassifier(alpha=1, max_iter=1000)\n", + "ysa.fit(x_train,y_train)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", + " 1, 1, 1, 1], dtype=int64)" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y_pred = ysa.predict(x_test)\n", + "y_pred" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 12],\n", + " [ 0, 58]], dtype=int64)" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cnf_matrix = metrics.confusion_matrix(y_test, y_pred)\n", + "cnf_matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Accuracy: 0.8285714285714286\n", + "Precision: 0.8285714285714286\n", + "Recall: 1.0\n" + ] + } + ], + "source": [ + "print('Accuracy:' ,metrics.accuracy_score(y_test,y_pred))\n", + "print(\"Precision:\",metrics.precision_score(y_test, y_pred))\n", + "print(\"Recall:\",metrics.recall_score(y_test, y_pred))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "****************************\n", + "## Model Comparison\n", + "We have deployed nine machine learning algorithms and every algorithm is deployed successfully without any hesitation. We have checked the accuracy of the models based on the accuracy score of each of the models. Now let's take a look at the scores of each models.\n", + "\n", + "|Name of the Model|Accuracy Score|\n", + "|:---:|:---:|\n", + "|Logistic Regression|82.86|\n", + "|Decision Tree Classifier|82.86|\n", + "|Random Forest Classifier|82.86|\n", + "|Naive Bayes Algorithm|82.86|\n", + "|KNN Algorithm|82.86|\n", + "|Support Vector Machine Algorithm|82.86|\n", + "|Gradient Boosting Algorithm|82.86|\n", + "|AdaBoosting Classifier|82.86|\n", + "|Artificial Neural Network|82.86|\n", + "\n", + "***************************************\n", + "## Conclusion\n", + "* For this project we have deployed nine different algortihms and every algorithm provides more or less same accuracy score, which is 82.86.\n", + "* To predict the kidney stone using this dataset we can use any of the above mentioned algorithms or models and deploy the final model.\n", + "* Here data limitation comes into play and it restricts the model to be more accurate.\n", + "* To make the model more accurate we need more attributes in the dataset and also the number of data must be increased so that the model can be trained better.\n", + "* Apart from the data limitations created by the dataset, the models are successfully deployed, and are predicting the outcome accurate enough.\n", + "* To work with this dataset in my opinion, every one should go with simple logistic regression, as that would be enough!\n", + "\n", + "Hooray!! The models are deployed successfully!\n", + "\n", + "\n", + "### Hope this project will help you! Thank you!" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + }, + "papermill": { + "default_parameters": {}, + "duration": 8.500556, + "end_time": "2021-02-27T08:07:12.940949", + "environment_variables": {}, + "exception": null, + "input_path": "__notebook__.ipynb", + "output_path": "__notebook__.ipynb", + "parameters": {}, + "start_time": "2021-02-27T08:07:04.440393", + "version": "2.2.2" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Kidney Stone Prediction/Model/README.md b/Kidney Stone Prediction/Model/README.md new file mode 100644 index 000000000..ca1df3589 --- /dev/null +++ b/Kidney Stone Prediction/Model/README.md @@ -0,0 +1,71 @@ +# Kidney Stone Prediction +A small, hard deposit that forms in the kidneys and is often painful when passed. + +Kidney stones are hard deposits of minerals and acid salts that stick together in concentrated urine. They can be painful when passing through the urinary tract, but usually don't cause permanent damage. + +The most common symptom is severe pain, usually in the side of the abdomen, that's often associated with nausea. +Treatment includes pain relievers and drinking lots of water to help pass the stone. Medical procedures may be required to remove or break up larger stones. + +Treatment includes pain relievers and drinking lots of water to help pass the stone. Medical procedures may be required to remove or break up larger stones. + + + +## Dataset +The dataset which is used here, is collected from Kaggle website. Here is the link of the dataset : https://www.kaggle.com/utkarshxy/kidney-stone-data. + +## Goal +The goal of this project is to create a prediction model which will predict the success rate of kidney stone operation based on the stone's size and type of treatment. +************************************************************ + +## What Have I done? +1. Importing all the required libraries. Check [`requirements.txt`] +2. Upload the dataset and the Jupyter Notebook file. +3. Data Cleaning +4. Data Visualization +5. Prediction Models + - KNN Algorithm + - Logistic Regression + - Random Forest Classifier + - Decision Tree Classifier + - Support Vector Machine Classifier + - AdaBoost Classifier + - Gradient Boosting Classifier + - Gaussian Naive Bayes Classifier + - MLP Classifier +6. Model comparison +7. Conclusion + +****************************************************************** +## Libraries used +1. Numpy +2. Pandas +3. Matplotlib +4. Sklearn +5. Seaborn + +********************************** + +## Model Comparison +We have deployed nine machine learning algorithms and every algorithm is deployed successfully without any hesitation. We have checked the accuracy of the models based on the accuracy score of each of the models. Now let's take a look at the scores of each models. + +|Name of the Model|Accuracy Score| +|:---:|:---:| +|Logistic Regression|82.86| +|Decision Tree Classifier|82.86| +|Random Forest Classifier|82.86| +|Naive Bayes Algorithm|82.86| +|KNN Algorithm|82.86| +|Support Vector Machine Algorithm|82.86| +|Gradient Boosting Algorithm|82.86| +|AdaBoosting Classifier|82.86| +|Artificial Neural Network|82.86| + +*************************************** +## Conclusion +* For this project we have deployed nine different algortihms and every algorithm provides more or less same accuracy score, which is 82.86. +* To predict the kidney stone using this dataset we can use any of the above mentioned algorithms or models and deploy the final model. +* Here data limitation comes into play and it restricts the model to be more accurate. +* To make the model more accurate we need more attributes in the dataset and also the number of data must be increased so that the model can be trained better. +* Apart from the data limitations created by the dataset, the models are successfully deployed, and are predicting the outcome accurate enough. +* To work with this dataset in my opinion, every one should go with simple logistic regression, as that would be enough! +****************************************** diff --git a/Kidney Stone Prediction/requirements.txt b/Kidney Stone Prediction/requirements.txt new file mode 100644 index 000000000..b332610db --- /dev/null +++ b/Kidney Stone Prediction/requirements.txt @@ -0,0 +1,7 @@ +The required libraries for this project work + +sklearn +seaborn +Numpy==1.19.2 +pandas==1.2.4 +matplotlib==3.4.2