Skip to content

Commit

Permalink
Run this in Google Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
realaryanpatil committed Aug 19, 2021
1 parent cf51f5f commit 24278ec
Showing 1 changed file with 186 additions and 0 deletions.
186 changes: 186 additions & 0 deletions Platinum.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Platinum.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyO1l5XXdyXWCTVcO6/be7EV"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "sLPCsQmoV8xs"
},
"source": [
"# Platinum heart & liver disease predictor\n",
"Class 12 CS project by Aryan Patil, Priyansh Mishra and Rithwik Anand"
]
},
{
"cell_type": "code",
"metadata": {
"id": "7Dg7a2vVHZos"
},
"source": [
"#github.com/realaryanpatil/Platinum"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "7XpVe5YIYVJt"
},
"source": [
"### This program requires datasets to work. Please download liver.csv and heart.csv from the [repository](https://github.com/realaryanpatil/Platinum) "
]
},
{
"cell_type": "code",
"metadata": {
"id": "YEWYKEaNY-Ed"
},
"source": [
"import pandas as pd\n",
"\n",
"def trainheart(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11):\n",
" dataset = pd.read_csv('medical.csv')\n",
" X = dataset.iloc[:, :-1].values\n",
" y = dataset.iloc[:, -1].values\n",
" \n",
" from sklearn.model_selection import train_test_split\n",
" X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)\n",
"\n",
" from sklearn.preprocessing import StandardScaler\n",
" sc = StandardScaler()\n",
" X_train = sc.fit_transform(X_train)\n",
" X_test = sc.transform(X_test)\n",
"\n",
" from sklearn.naive_bayes import GaussianNB\n",
" classifier = GaussianNB()\n",
" classifier.fit(X_train, y_train)\n",
"\n",
" result = classifier.predict(sc.transform([[q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11]]))\n",
" output = int(result)\n",
" if output == 1:\n",
" a1 = \"The patient is at a high risk of heart failure.\"\n",
" else:\n",
" a1 = \"The patient is at a low risk of heart failure.\"\n",
" print(a1)\n",
"\n",
"def livertrain(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10):\n",
" dataset = pd.read_csv('liver.csv')\n",
" X = dataset.iloc[:, :-1].values\n",
" y = dataset.iloc[:, -1].values\n",
" \n",
" from sklearn.model_selection import train_test_split\n",
" X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)\n",
"\n",
" from sklearn.preprocessing import StandardScaler\n",
" sc = StandardScaler()\n",
" X_train = sc.fit_transform(X_train)\n",
" X_test = sc.transform(X_test)\n",
"\n",
" from sklearn.naive_bayes import GaussianNB\n",
" classifier = GaussianNB()\n",
" classifier.fit(X_train, y_train)\n",
"\n",
" result = classifier.predict(sc.transform([[q1,q2,q3,q4,q5,q6,q7,q8,q9,q10]]))\n",
" output = int(result)\n",
" if output == 1:\n",
" a1 = \"The patient is at a high risk of liver disease.\"\n",
" else:\n",
" a1 = \"The patient is at a low risk of liver disease.\"\n",
" print(a1)\n",
"\n",
"question = input(\"\"\"Welcome to Platinum Argos [V1.0], A Naive Bayes classification system to detect heart/liver disease.\n",
"\n",
"Please select your choice below:\n",
"[1] Heart failure risk analysis\n",
"[2] Liver disease risk analysis\n",
"--------------------------------------------------------------------------------------------------\n",
":\"\"\")\n",
"\n",
"if question == '1' or question == 'heart':\n",
" print('---------------------------------------heart-----------------------------------------------')\n",
" r1 = input(\"Patient age: \")\n",
" r2 = input(\"Is the patient suffering from anemia? (y/n): \")\n",
" if r2 == 'y':\n",
" r2 = 1\n",
" else:\n",
" r2 = 0\n",
" r3 = input(\"Creatine Phosphokinase levels (in micrograms per litre): \")\n",
" r4 = input(\"Is the patient suffering from diabetes? (y/n): \")\n",
" if r4 == 'y':\n",
" r4 = 1\n",
" else:\n",
" r4 = 0\n",
" r5 = input(\"Ejection Fraction (in %): \")\n",
" r6 = input(\"Is the patient suffering from hypertension? (y/n): \")\n",
" if r6 == 'y':\n",
" r6 = 1\n",
" else:\n",
" r6 = 0\n",
" r7 = input(\"Number of platelets: \")\n",
" r8 = input(\"Serum Creatine levels: \")\n",
" r9 = input(\"Serum Sodium levels: \")\n",
" r10 = input(\"Gender (m/f): \")\n",
" if r10 == 'm':\n",
" r10 = 1\n",
" else:\n",
" r10 = 0\n",
" r11 = input(\"Does the patient smoke? (y/n): \")\n",
" if r11 == 'y':\n",
" r11 = 1\n",
" else:\n",
" r11 = 0\n",
"\n",
" trainheart(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11)\n",
"\n",
"elif question == \"2\" or question == \"liver\":\n",
" print('---------------------------------------liver-----------------------------------------------')\n",
" r1 = input(\"Patient age: \")\n",
" r2 = input(\"Patient gender (m/f): \")\n",
" if r2 == 'm':\n",
" r2 = 1\n",
" else:\n",
" r2 = 0\n",
" r3 = input(\"Total Bilirubin: \")\n",
" r4 = input(\"Direct Bilirubin: \")\n",
" r5 = input(\"Alkaline Phosphotase: \")\n",
" r6 = input(\"Alamine Aminotransferase:\")\n",
" r7 = input(\"Aspartate Aminotransferase: \")\n",
" r8 = input(\"Total Protiens: \")\n",
" r9 = input(\"Albumin levels: \")\n",
" r10 = input(\"Albumin and Globulin Ratio: \")\n",
"\n",
" livertrain(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10)\n",
"\n",
"else:\n",
" print(\"Wrong input. Please try again.\")\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n"
],
"execution_count": null,
"outputs": []
}
]
}

0 comments on commit 24278ec

Please sign in to comment.