Disease stage prediction

parent 24396e26
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "43e9cb3a",
"metadata": {},
"outputs": [],
"source": [
"from tkinter import *\n",
"from tkinter import messagebox\n",
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fdfc1c1c",
"metadata": {},
"outputs": [],
"source": [
"list1=['weight_loss','loss_of_appetite','swollen_joints','lameness','nasal_discharge','ocular_discharge','ruffled_feathers','diarrhea','mites','egg_production_decrease','inability_to_absorb_nutrients','distinctive_bumps','warts','stunted_growth','edema_in_the_comb','discoloration','coughing_and_sneezing','swelling','rales','gasping','muscular_tremors','opisthotonus','Closed_eyes','facial_swelling','increased_thirst','lethargy','profuse_tear_secretion','facial_skin_edema','progressing_tremors','drowsy','head_droop','laying_on_ground','Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas','Crusty_looking_eyes','hyperemic','high_fever','paralysis','dehydration','unkempt_feathers','yellow_fecal_droppings','dullness','reduction_in_the_size_of_the_egg','Rough_scaly_feathers','bloated_abdomen','brittle_bones','redness_or_scrabs_on_skin']"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "47b1f0a8",
"metadata": {},
"outputs": [],
"source": [
"pdisease=['Stage 1','Stage 2','Stage 3']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "481e4990",
"metadata": {},
"outputs": [],
"source": [
"list2=[]\n",
"for x in range(0,len(list1)):\n",
" list2.append(0)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fcdbabd8",
"metadata": {},
"outputs": [],
"source": [
"# TESTING DATA\n",
"tr=pd.read_csv(\"Testing2.csv\")\n",
"tr.replace({'stage':{'Stage 1':0,'Stage 2':1,'Stage 3':2}},inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "3ce3dbab",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 1, 1, ..., 1, 1, 0], dtype=int64)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Xtest= tr[list1]\n",
"ytest = tr[[\"stage\"]]\n",
"np.ravel(ytest)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "2ac02040",
"metadata": {},
"outputs": [],
"source": [
"# TRAINING DATA\n",
"df=pd.read_csv(\"Training2.csv\")\n",
"\n",
"df.replace({'stage':{'Stage 1':0,'Stage 2':1,'Stage 3':2}},inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d239614c",
"metadata": {},
"outputs": [],
"source": [
"X= df[list1]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "9e810957",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 1, 1, ..., 1, 1, 0], dtype=int64)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y = df[[\"stage\"]]\n",
"np.ravel(y)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "612d9452",
"metadata": {},
"outputs": [],
"source": [
"def message():\n",
" if (Symptom1.get() == \"None\" and Symptom2.get() == \"None\" and Symptom3.get() == \"None\" and Symptom4.get() == \"None\" and Symptom5.get() == \"None\"):\n",
" messagebox.showinfo(\"OPPS!!\", \"PLEASE SELECT THE SYMPTOMS???\")\n",
" else :\n",
" StagePrediction()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "aa320320",
"metadata": {},
"outputs": [],
"source": [
"def StagePrediction():\n",
" from sklearn.naive_bayes import MultinomialNB\n",
" gnb = MultinomialNB()\n",
" gnb=gnb.fit(X,np.ravel(y))\n",
" from sklearn.metrics import accuracy_score\n",
" ypred = gnb.predict(Xtest)\n",
" print(accuracy_score(ytest, ypred))\n",
" print(accuracy_score(ytest, ypred, normalize=False))\n",
"\n",
" Poultry_symptoms = [Symptom1.get(),Symptom2.get(),Symptom3.get(),Symptom4.get(),Symptom5.get()]\n",
"\n",
" for k in range(0,len(list1)):\n",
" for z in Poultry_symptoms:\n",
" if(z==list1[k]):\n",
" list2[k]=1\n",
"\n",
" intest = [list2]\n",
" predict = gnb.predict(intest)\n",
" predicted=predict[0]\n",
"\n",
" h='no'\n",
" for a in range(0,len(pdisease)):\n",
" if(pdisease[predicted] == pdisease[a]):\n",
" h='yes'\n",
" break\n",
"\n",
" if (h=='yes'):\n",
" t3.delete(\"1.0\", END)\n",
" t3.insert(END, pdisease[a])\n",
" else:\n",
" t3.delete(\"1.0\", END)\n",
" t3.insert(END, \"No Stage Found\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "178cdfa9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'bd': ('bd', '-borderwidth'),\n",
" 'borderwidth': ('borderwidth',\n",
" 'borderWidth',\n",
" 'BorderWidth',\n",
" <string object: '0'>,\n",
" 0),\n",
" 'class': ('class', 'class', 'Class', 'Toplevel', 'Tk'),\n",
" 'menu': ('menu', 'menu', 'Menu', '', ''),\n",
" 'relief': ('relief', 'relief', 'Relief', <string object: 'flat'>, 'flat'),\n",
" 'screen': ('screen', 'screen', 'Screen', '', ''),\n",
" 'use': ('use', 'use', 'Use', '', ''),\n",
" 'background': ('background',\n",
" 'background',\n",
" 'Background',\n",
" <string object: 'SystemButtonFace'>,\n",
" 'SystemButtonFace'),\n",
" 'bg': ('bg', '-background'),\n",
" 'colormap': ('colormap', 'colormap', 'Colormap', '', ''),\n",
" 'container': ('container', 'container', 'Container', 0, 0),\n",
" 'cursor': ('cursor', 'cursor', 'Cursor', '', ''),\n",
" 'height': ('height', 'height', 'Height', <string object: '0'>, 0),\n",
" 'highlightbackground': ('highlightbackground',\n",
" 'highlightBackground',\n",
" 'HighlightBackground',\n",
" <string object: 'SystemButtonFace'>,\n",
" 'SystemButtonFace'),\n",
" 'highlightcolor': ('highlightcolor',\n",
" 'highlightColor',\n",
" 'HighlightColor',\n",
" <string object: 'SystemWindowFrame'>,\n",
" 'SystemWindowFrame'),\n",
" 'highlightthickness': ('highlightthickness',\n",
" 'highlightThickness',\n",
" 'HighlightThickness',\n",
" <string object: '0'>,\n",
" 0),\n",
" 'padx': ('padx', 'padX', 'Pad', <string object: '0'>, <string object: '0'>),\n",
" 'pady': ('pady', 'padY', 'Pad', <string object: '0'>, <string object: '0'>),\n",
" 'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', '0', '0'),\n",
" 'visual': ('visual', 'visual', 'Visual', '', ''),\n",
" 'width': ('width', 'width', 'Width', <string object: '0'>, 0)}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"root = Tk()\n",
"root.title(\" Poultry Disease Prediction \")\n",
"root.configure()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0f3a7ef2",
"metadata": {},
"outputs": [],
"source": [
"Symptom1 = StringVar()\n",
"Symptom1.set(None)\n",
"Symptom2 = StringVar()\n",
"Symptom2.set(None)\n",
"Symptom3 = StringVar()\n",
"Symptom3.set(None)\n",
"Symptom4 = StringVar()\n",
"Symptom4.set(None)\n",
"Symptom5 = StringVar()\n",
"Symptom5.set(None)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "2dc426ce",
"metadata": {},
"outputs": [],
"source": [
"w2 = Label(root, justify=CENTER, text=\" Poultry Disease Prediction \")\n",
"w2.config(font=(\"bold italic\", 40,\"bold\"))\n",
"w2.grid(row=1, column=0, columnspan=4, padx=250)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "65924ce7",
"metadata": {},
"outputs": [],
"source": [
"NameLbl1 = Label(root, text=\"\")\n",
"NameLbl1.config(font=(\"italic\", 20))\n",
"NameLbl1.grid(row=5, column=3, pady=10, sticky=E)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5eaa4026",
"metadata": {},
"outputs": [],
"source": [
"S1Lbl = Label(root, text=\"Symptom 01\")\n",
"S1Lbl.config(font=(\"bold italic\", 20))\n",
"S1Lbl.grid(row=7, column=3, pady=10 , sticky=W )"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "1e0cc15f",
"metadata": {},
"outputs": [],
"source": [
"S2Lbl = Label(root, text=\"Symptom 02\")\n",
"S2Lbl.config(font=(\"bold italic\", 20))\n",
"S2Lbl.grid(row=8, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "e705cbb3",
"metadata": {},
"outputs": [],
"source": [
"S3Lbl = Label(root, text=\"Symptom 03\")\n",
"S3Lbl.config(font=(\"bold italic\", 20))\n",
"S3Lbl.grid(row=9, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "5e239fcd",
"metadata": {},
"outputs": [],
"source": [
"S4Lbl = Label(root, text=\"Symptom 04\")\n",
"S4Lbl.config(font=(\"bold italic\", 20))\n",
"S4Lbl.grid(row=10, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "eaad190b",
"metadata": {},
"outputs": [],
"source": [
"S5Lbl = Label(root, text=\"Symptom 05\")\n",
"S5Lbl.config(font=(\"bold italic\", 20))\n",
"S5Lbl.grid(row=11, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "858bf515",
"metadata": {},
"outputs": [],
"source": [
"lr = Button(root, text=\"Prediction\",height=2, width=25, command=message, fg='black', bg='#87CEFA')\n",
"lr.config(font=(\"bold italic\", 20, \"bold\"))\n",
"lr.grid(row=15, column=3, pady=20, padx=200)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "f014f295",
"metadata": {},
"outputs": [],
"source": [
"OPTIONS = sorted(list1)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "28bb5ad8",
"metadata": {},
"outputs": [],
"source": [
"S1Op = OptionMenu(root, Symptom1,*OPTIONS)\n",
"S1Op.grid(row=7, column=4, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "c4511869",
"metadata": {},
"outputs": [],
"source": [
"S2Op = OptionMenu(root, Symptom2,*OPTIONS)\n",
"S2Op.grid(row=8, column=4, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "d39c868a",
"metadata": {},
"outputs": [],
"source": [
"S3Op = OptionMenu(root, Symptom3,*OPTIONS)\n",
"S3Op.grid(row=9, column=4, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "79cd6647",
"metadata": {},
"outputs": [],
"source": [
"S4Op = OptionMenu(root, Symptom4,*OPTIONS)\n",
"S4Op.grid(row=10, column=4, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "27446c34",
"metadata": {},
"outputs": [],
"source": [
"S5Op = OptionMenu(root, Symptom5,*OPTIONS)\n",
"S5Op.grid(row=11, column=4, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "b71d0caf",
"metadata": {},
"outputs": [],
"source": [
"NameLbl = Label(root, text=\"\")\n",
"NameLbl.config(font=(\"italic\", 20))\n",
"NameLbl.grid(row=13, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "6509ee5f",
"metadata": {},
"outputs": [],
"source": [
"NameLbl = Label(root, text=\"\")\n",
"NameLbl.config(font=(\"italic\", 15))\n",
"NameLbl.grid(row=18, column=3, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "9170b123",
"metadata": {},
"outputs": [],
"source": [
"t3 = Text(root, height=3, width=30)\n",
"t3.config(font=(\"italic\", 20))\n",
"t3.grid(row=20, column=3 , padx=10)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "3e0345ae",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.5337837837837838\n",
"553\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\ACER\\anaconda3\\lib\\site-packages\\sklearn\\base.py:450: UserWarning: X does not have valid feature names, but MultinomialNB was fitted with feature names\n",
" warnings.warn(\n"
]
}
],
"source": [
"root.mainloop()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f5f82a44",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a11c036",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment