Commit 3ef85942 authored by Anuththara K.G.S.N's avatar Anuththara K.G.S.N

Replace Severity_Level_Prediction.py

parent a26e0ae0
#!/usr/bin/env python
# coding: utf-8
# Severity Level Prediction
# In[1]:
#Importing Libraries
from mpl_toolkits.mplot3d import Axes3D
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
from tkinter import *
import numpy as np
import pandas as pd
import os
# In[2]:
#List of the symptoms is listed here in list l1.
l1=['Yeast_Visibility-ears,armpits,_or_paws','Yeast_Visibility-around_half_of_the_body','Yeast_Visibility-whole_body',
'Redness-pink_or_red_skin','Redness-red_skin','Redness-gray_or_black_skin',
'No_unpleasant_Smell','Musty_smell','Extreme_musty_smell',
'No_Itching_and_Scratching','Itching_and_Scratching-time_to_time','Itching_and_Scratching-constantly',
'No_Thickened_Skin','Thickened_Skin','Extremely_Thickened_Skin(Elephant_skin_appearance)',
'No_Hair_Loss','Starting_Hair_Loss','Hair_Loss',
'No_Hearing_Issues','Hearing_Issues','Deafness']
# In[3]:
#List of Severity Levels.
level=['Primary','Secondary','Tertiary']
#level = [df['Prediction'].unique()]
# In[4]:
l2=[]
for i in range(0,len(l1)):
l2.append(0)
print(l2)
# In[5]:
#Reading the training.csv file
df=pd.read_csv("severity level.csv")
DF=pd.read_csv("severity level.csv" , index_col='Prediction')
#Replace the values in the imported file by pandas by the inbuilt function replace in pandas.
df.replace({'Prediction':{'Primary':0,'Secondary':1,'Tertiary':2}},inplace=True)
#df.head()
DF.head()
# In[6]:
X= df[l1]
y = df[["Prediction"]]
np.ravel(y)
print(X)
# In[7]:
#Reading the testing.csv file
tr=pd.read_csv("testing.csv")
#Using inbuilt function replace in pandas for replacing the values
tr.replace({'Prediction':{'Primary':0,'Secondary':1,'Tertiary':2}},inplace=True)
tr.head()
# In[8]:
X_test= tr[l1]
y_test = tr[["Prediction"]]
np.ravel(y_test)
print(X_test)
# In[9]:
print(y_test)
# Decision Tree Algorithm
# In[10]:
root = Tk()
pred1=StringVar()
def DecisionTree():
if len(NameEn.get()) == 0:
pred1.set(" ")
comp=messagebox.askokcancel("System","Please fill the breed of your pet !")
if comp:
root.mainloop()
elif((Symptom1.get()=="Select Here") or (Symptom2.get()=="Select Here") ):
pred1.set(" ")
sym=messagebox.askokcancel("System","Please fill atleast first two Symptoms")
if sym:
root.mainloop()
else:
from sklearn import tree
clf3 = tree.DecisionTreeClassifier()
clf3 = clf3.fit(X,y)
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
y_pred=clf3.predict(X_test)
print("Decision Tree")
print("Accuracy")
print(accuracy_score(y_test, y_pred))
print(accuracy_score(y_test, y_pred,normalize=False))
print("Confusion matrix")
conf_matrix=confusion_matrix(y_test,y_pred)
print(conf_matrix)
psymptoms = [Symptom1.get(),Symptom2.get(),Symptom3.get(),Symptom4.get(),Symptom5.get(),Symptom6.get(),Symptom7.get()]
for k in range(0,len(l1)):
for z in psymptoms:
if(z==l1[k]):
l2[k]=1
inputtest = [l2]
predict = clf3.predict(inputtest)
predicted=predict[0]
h='no'
for a in range(0,len(level)):
if(predicted == a):
h='yes'
break
if (h=='yes'):
pred1.set(" ")
pred1.set(level[a])
else:
pred1.set(" ")
pred1.set("Not Found")
# Random Forest Algorithm
# In[11]:
pred2=StringVar()
def randomforest():
if len(NameEn.get()) == 0:
pred1.set(" ")
comp=messagebox.askokcancel("System","Please fill the breed of your pet !")
if comp:
root.mainloop()
elif((Symptom1.get()=="Select Here") or (Symptom2.get()=="Select Here")):
pred1.set(" ")
sym=messagebox.askokcancel("System","Please fill atleast first two Symptoms")
if sym:
root.mainloop()
else:
from sklearn.ensemble import RandomForestClassifier
clf4 = RandomForestClassifier(n_estimators=100)
clf4 = clf4.fit(X,np.ravel(y))
# calculating accuracy
from sklearn.metrics import classification_report,confusion_matrix,accuracy_score
y_pred=clf4.predict(X_test)
print("Random Forest")
print("Accuracy")
print(accuracy_score(y_test, y_pred))
print(accuracy_score(y_test, y_pred,normalize=False))
print("Confusion matrix")
conf_matrix=confusion_matrix(y_test,y_pred)
print(conf_matrix)
psymptoms = [Symptom1.get(),Symptom2.get(),Symptom3.get(),Symptom4.get(),Symptom5.get(),Symptom6.get(),Symptom7.get()]
for k in range(0,len(l1)):
for z in psymptoms:
if(z==l1[k]):
l2[k]=1
inputtest = [l2]
predict = clf4.predict(inputtest)
predicted=predict[0]
h='no'
for a in range(0,len(level)):
if(predicted == a):
h='yes'
break
if (h=='yes'):
pred2.set(" ")
pred2.set(level[a])
else:
pred2.set(" ")
pred2.set("Not Found")
# Building Graphical User Interface
# In[12]:
#Tk class is used to create a root window
root.configure(background='Ivory')
root.title('Skin Disease Severity Level Predictor System')
root.resizable(0,0)
# In[13]:
Symptom1 = StringVar()
Symptom1.set("Select Here")
Symptom2 = StringVar()
Symptom2.set("Select Here")
Symptom3 = StringVar()
Symptom3.set("Select Here")
Symptom4 = StringVar()
Symptom4.set("Select Here")
Symptom5 = StringVar()
Symptom5.set("Select Here")
Symptom6 = StringVar()
Symptom6.set("Select Here")
Symptom7 = StringVar()
Symptom7.set("Select Here")
Name = StringVar()
# In[14]:
prev_win=None
def Reset():
global prev_win
Symptom1.set("Select Here")
Symptom2.set("Select Here")
Symptom3.set("Select Here")
Symptom4.set("Select Here")
Symptom5.set("Select Here")
Symptom6.set("Select Here")
Symptom7.set("Select Here")
NameEn.delete(first=0,last=100)
pred1.set(" ")
pred2.set(" ")
try:
prev_win.destroy()
prev_win=None
except AttributeError:
pass
# In[15]:
from tkinter import messagebox
def Exit():
qExit=messagebox.askyesno("System","Do you want to exit the system ?")
if qExit:
root.destroy()
exit()
# In[16]:
#Headings for the GUI written at the top of GUI
w2 = Label(root, justify=LEFT, text="Skin Disease Severity Level Prediction", fg="Black", bg="Ivory")
w2.config(font=("Times",30,"bold"))
w2.grid(row=1, column=0, columnspan=2, padx=100)
# In[17]:
#Label for the name
NameLb = Label(root, text="Breed of the Pet *", fg="Dark Blue", bg="Ivory")
NameLb.config(font=("Times",15,"bold"))
NameLb.grid(row=6, column=0, pady=15, sticky=W)
# In[18]:
#Creating Labels for the symtoms
S1Lb = Label(root, text="Symptom 1 *", fg="Black", bg="Ivory")
S1Lb.config(font=("Times",15,"bold"))
S1Lb.grid(row=7, column=0, pady=10, sticky=W)
S2Lb = Label(root, text="Symptom 2 *", fg="Black", bg="Ivory")
S2Lb.config(font=("Times",15,"bold"))
S2Lb.grid(row=8, column=0, pady=10, sticky=W)
S3Lb = Label(root, text="Symptom 3", fg="Black",bg="Ivory")
S3Lb.config(font=("Times",15,"bold"))
S3Lb.grid(row=9, column=0, pady=10, sticky=W)
S4Lb = Label(root, text="Symptom 4", fg="Black", bg="Ivory")
S4Lb.config(font=("Times",15,"bold"))
S4Lb.grid(row=10, column=0, pady=10, sticky=W)
S5Lb = Label(root, text="Symptom 5", fg="Black", bg="Ivory")
S5Lb.config(font=("Times",15,"bold"))
S5Lb.grid(row=11, column=0, pady=10, sticky=W)
S6Lb = Label(root, text="Symptom 6", fg="Black", bg="Ivory")
S6Lb.config(font=("Times",15,"bold"))
S6Lb.grid(row=12, column=0, pady=10, sticky=W)
S7Lb = Label(root, text="Symptom 7", fg="Black", bg="Ivory")
S7Lb.config(font=("Times",15,"bold"))
S7Lb.grid(row=13, column=0, pady=10, sticky=W)
# In[19]:
#Labels for the different algorithms
lrLb = Label(root, text="DecisionTree", fg="black", bg="Light blue", width = 20)
lrLb.config(font=("Times",15,"bold"))
lrLb.grid(row=15, column=0, pady=10,sticky=W)
destreeLb = Label(root, text="RandomForest", fg="black", bg="Light blue", width = 20)
destreeLb.config(font=("Times",15,"bold"))
destreeLb.grid(row=17, column=0, pady=10, sticky=W)
OPTIONS = sorted(l1)
# In[20]:
#Taking breed-name as input from user
NameEn = Entry(root, textvariable=Name)
NameEn.grid(row=6, column=1)
#Taking Symptoms as input from the dropdown from the user
S1 = OptionMenu(root, Symptom1,*OPTIONS)
S1.grid(row=7, column=1)
S2 = OptionMenu(root, Symptom2,*OPTIONS)
S2.grid(row=8, column=1)
S3 = OptionMenu(root, Symptom3,*OPTIONS)
S3.grid(row=9, column=1)
S4 = OptionMenu(root, Symptom4,*OPTIONS)
S4.grid(row=10, column=1)
S5 = OptionMenu(root, Symptom5,*OPTIONS)
S5.grid(row=11, column=1)
S6 = OptionMenu(root, Symptom6,*OPTIONS)
S6.grid(row=12, column=1)
S7 = OptionMenu(root, Symptom7,*OPTIONS)
S7.grid(row=13, column=1)
# In[21]:
#Buttons for predicting the severity level using different algorithms
dst = Button(root, text="Prediction 1", command=DecisionTree,bg="Blue",fg="yellow")
dst.config(font=("Times",15,"bold"))
dst.grid(row=6, column=3,padx=10)
rnf = Button(root, text="Prediction 2", command=randomforest,bg="Blue",fg="yellow")
rnf.config(font=("Times",15,"bold"))
rnf.grid(row=7, column=3,padx=10)
rs = Button(root,text="Reset Inputs", command=Reset,bg="yellow",fg="purple",width=12)
rs.config(font=("Times",15,"bold"))
rs.grid(row=10,column=3,padx=10)
ex = Button(root,text="Exit System", command=Exit,bg="yellow",fg="purple",width=12)
ex.config(font=("Times",15,"bold"))
ex.grid(row=11,column=3,padx=10)
# In[22]:
#Showing the output of different algorithms
t1=Label(root,font=("Times",15,"bold"),text="Decision Tree",height=1,bg="Light green"
,width=40,fg="black",textvariable=pred1,relief="sunken").grid(row=15, column=1, padx=10)
t2=Label(root,font=("Times",15,"bold"),text="Random Forest",height=1,bg="Light green"
,width=40,fg="black",textvariable=pred2,relief="sunken").grid(row=17, column=1, padx=10)
# In[23]:
#calling this function because the application is ready to run
root.mainloop()
# In[ ]:
{
"cells": [
{
"cell_type": "markdown",
"id": "4d9f2d90",
"metadata": {},
"source": [
"Severity Level Prediction"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "89a28bd8",
"metadata": {},
"outputs": [],
"source": [
"#Importing Libraries\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"from sklearn.preprocessing import StandardScaler\n",
"import matplotlib.pyplot as plt\n",
"from tkinter import *\n",
"import numpy as np\n",
"import pandas as pd\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ffa7d78b",
"metadata": {},
"outputs": [],
"source": [
"#List of the symptoms is listed here in list l1.\n",
"l1=['Yeast_Visibility-ears,armpits,_or_paws','Yeast_Visibility-around_half_of_the_body','Yeast_Visibility-whole_body',\n",
" 'Redness-pink_or_red_skin','Redness-red_skin','Redness-gray_or_black_skin',\n",
" 'No_unpleasant_Smell','Musty_smell','Extreme_musty_smell',\n",
" 'No_Itching_and_Scratching','Itching_and_Scratching-time_to_time','Itching_and_Scratching-constantly',\n",
" 'No_Thickened_Skin','Thickened_Skin','Extremely_Thickened_Skin(Elephant_skin_appearance)',\n",
" 'No_Hair_Loss','Starting_Hair_Loss','Hair_Loss',\n",
" 'No_Hearing_Issues','Hearing_Issues','Deafness']"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "88ebf3aa",
"metadata": {},
"outputs": [],
"source": [
"#List of Severity Levels.\n",
"level=['Primary','Secondary','Tertiary']\n",
"\n",
"#level = [df['Prediction'].unique()]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1bad964f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
]
}
],
"source": [
"l2=[]\n",
"for i in range(0,len(l1)):\n",
" l2.append(0)\n",
"print(l2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a763e537",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Yeast_Visibility-ears,armpits,_or_paws</th>\n",
" <th>Yeast_Visibility-around_half_of_the_body</th>\n",
" <th>Yeast_Visibility-whole_body</th>\n",
" <th>Redness-pink_or_red_skin</th>\n",
" <th>Redness-red_skin</th>\n",
" <th>Redness-gray_or_black_skin</th>\n",
" <th>No_unpleasant_Smell</th>\n",
" <th>Musty_smell</th>\n",
" <th>Extreme_musty_smell</th>\n",
" <th>No_Itching_and_Scratching</th>\n",
" <th>...</th>\n",
" <th>Itching_and_Scratching-constantly</th>\n",
" <th>No_Thickened_Skin</th>\n",
" <th>Thickened_Skin</th>\n",
" <th>Extremely_Thickened_Skin(Elephant_skin_appearance)</th>\n",
" <th>No_Hair_Loss</th>\n",
" <th>Starting_Hair_Loss</th>\n",
" <th>Hair_Loss</th>\n",
" <th>No_Hearing_Issues</th>\n",
" <th>Hearing_Issues</th>\n",
" <th>Deafness</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Prediction</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Primary</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Primary</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Primary</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Primary</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Primary</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" Yeast_Visibility-ears,armpits,_or_paws \\\n",
"Prediction \n",
"Primary 1 \n",
"Primary 1 \n",
"Primary 1 \n",
"Primary 1 \n",
"Primary 1 \n",
"\n",
" Yeast_Visibility-around_half_of_the_body \\\n",
"Prediction \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"\n",
" Yeast_Visibility-whole_body Redness-pink_or_red_skin \\\n",
"Prediction \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"\n",
" Redness-red_skin Redness-gray_or_black_skin No_unpleasant_Smell \\\n",
"Prediction \n",
"Primary 0 0 1 \n",
"Primary 0 0 1 \n",
"Primary 0 0 1 \n",
"Primary 0 0 1 \n",
"Primary 0 0 1 \n",
"\n",
" Musty_smell Extreme_musty_smell No_Itching_and_Scratching ... \\\n",
"Prediction ... \n",
"Primary 0 0 1 ... \n",
"Primary 0 0 1 ... \n",
"Primary 0 0 1 ... \n",
"Primary 0 0 1 ... \n",
"Primary 0 0 1 ... \n",
"\n",
" Itching_and_Scratching-constantly No_Thickened_Skin \\\n",
"Prediction \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"\n",
" Thickened_Skin \\\n",
"Prediction \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"\n",
" Extremely_Thickened_Skin(Elephant_skin_appearance) No_Hair_Loss \\\n",
"Prediction \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"Primary 0 1 \n",
"\n",
" Starting_Hair_Loss Hair_Loss No_Hearing_Issues Hearing_Issues \\\n",
"Prediction \n",
"Primary 0 0 1 0 \n",
"Primary 0 0 1 0 \n",
"Primary 0 0 1 0 \n",
"Primary 0 0 1 0 \n",
"Primary 0 0 1 0 \n",
"\n",
" Deafness \n",
"Prediction \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"Primary 0 \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Reading the training.csv file\n",
"df=pd.read_csv(\"severity level.csv\")\n",
"DF=pd.read_csv(\"severity level.csv\" , index_col='Prediction')\n",
"\n",
"#Replace the values in the imported file by pandas by the inbuilt function replace in pandas.\n",
"\n",
"df.replace({'Prediction':{'Primary':0,'Secondary':1,'Tertiary':2}},inplace=True)\n",
"DF.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "87e4e740",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Yeast_Visibility-ears,armpits,_or_paws \\\n",
"0 1 \n",
"1 1 \n",
"2 1 \n",
"3 1 \n",
"4 1 \n",
"5 1 \n",
"6 1 \n",
"7 1 \n",
"8 1 \n",
"9 1 \n",
"10 1 \n",
"11 1 \n",
"12 1 \n",
"13 1 \n",
"14 1 \n",
"15 1 \n",
"16 1 \n",
"17 1 \n",
"18 1 \n",
"19 0 \n",
"20 0 \n",
"21 0 \n",
"22 0 \n",
"23 0 \n",
"24 0 \n",
"25 0 \n",
"26 0 \n",
"27 0 \n",
"28 0 \n",
"29 0 \n",
"30 0 \n",
"31 0 \n",
"32 0 \n",
"33 0 \n",
"34 0 \n",
"35 0 \n",
"36 0 \n",
"37 0 \n",
"38 0 \n",
"39 0 \n",
"40 0 \n",
"41 0 \n",
"42 0 \n",
"43 0 \n",
"44 0 \n",
"45 0 \n",
"46 0 \n",
"47 0 \n",
"48 0 \n",
"49 0 \n",
"50 0 \n",
"51 0 \n",
"52 0 \n",
"53 0 \n",
"54 0 \n",
"55 0 \n",
"56 0 \n",
"57 0 \n",
"58 0 \n",
"\n",
" Yeast_Visibility-around_half_of_the_body Yeast_Visibility-whole_body \\\n",
"0 0 0 \n",
"1 0 0 \n",
"2 0 0 \n",
"3 0 0 \n",
"4 0 0 \n",
"5 0 0 \n",
"6 0 0 \n",
"7 0 0 \n",
"8 0 0 \n",
"9 0 0 \n",
"10 0 0 \n",
"11 0 0 \n",
"12 0 0 \n",
"13 0 0 \n",
"14 0 0 \n",
"15 0 0 \n",
"16 0 0 \n",
"17 0 0 \n",
"18 0 0 \n",
"19 1 0 \n",
"20 1 0 \n",
"21 1 0 \n",
"22 1 0 \n",
"23 1 0 \n",
"24 1 0 \n",
"25 1 0 \n",
"26 1 0 \n",
"27 1 0 \n",
"28 1 0 \n",
"29 1 0 \n",
"30 1 0 \n",
"31 1 0 \n",
"32 1 0 \n",
"33 1 0 \n",
"34 1 0 \n",
"35 1 0 \n",
"36 1 0 \n",
"37 1 0 \n",
"38 1 0 \n",
"39 0 1 \n",
"40 0 1 \n",
"41 0 1 \n",
"42 0 1 \n",
"43 0 1 \n",
"44 0 1 \n",
"45 0 1 \n",
"46 0 1 \n",
"47 0 1 \n",
"48 0 1 \n",
"49 0 1 \n",
"50 0 1 \n",
"51 0 1 \n",
"52 0 1 \n",
"53 0 1 \n",
"54 0 1 \n",
"55 0 1 \n",
"56 0 1 \n",
"57 0 1 \n",
"58 0 1 \n",
"\n",
" Redness-pink_or_red_skin Redness-red_skin Redness-gray_or_black_skin \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 1 0 0 \n",
"5 1 0 0 \n",
"6 1 0 0 \n",
"7 1 0 0 \n",
"8 1 0 0 \n",
"9 1 0 0 \n",
"10 1 0 0 \n",
"11 1 0 0 \n",
"12 1 0 0 \n",
"13 1 0 0 \n",
"14 1 0 0 \n",
"15 1 0 0 \n",
"16 1 0 0 \n",
"17 1 0 0 \n",
"18 1 0 0 \n",
"19 0 1 0 \n",
"20 0 1 0 \n",
"21 0 1 0 \n",
"22 0 1 0 \n",
"23 0 1 0 \n",
"24 0 1 0 \n",
"25 0 1 0 \n",
"26 0 1 0 \n",
"27 0 1 0 \n",
"28 0 1 0 \n",
"29 0 1 0 \n",
"30 0 1 0 \n",
"31 0 1 0 \n",
"32 0 1 0 \n",
"33 0 1 0 \n",
"34 0 1 0 \n",
"35 0 1 0 \n",
"36 0 1 0 \n",
"37 0 1 0 \n",
"38 0 1 0 \n",
"39 0 0 1 \n",
"40 0 0 1 \n",
"41 0 0 1 \n",
"42 0 0 1 \n",
"43 0 0 1 \n",
"44 0 0 1 \n",
"45 0 0 1 \n",
"46 0 0 1 \n",
"47 0 0 1 \n",
"48 0 0 1 \n",
"49 0 0 1 \n",
"50 0 0 1 \n",
"51 0 0 1 \n",
"52 0 0 1 \n",
"53 0 0 1 \n",
"54 0 0 1 \n",
"55 0 0 1 \n",
"56 0 0 1 \n",
"57 0 0 1 \n",
"58 0 0 1 \n",
"\n",
" No_unpleasant_Smell Musty_smell Extreme_musty_smell \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 1 0 0 \n",
"5 1 0 0 \n",
"6 1 0 0 \n",
"7 1 0 0 \n",
"8 1 0 0 \n",
"9 1 0 0 \n",
"10 1 0 0 \n",
"11 1 0 0 \n",
"12 1 0 0 \n",
"13 1 0 0 \n",
"14 1 0 0 \n",
"15 1 0 0 \n",
"16 1 0 0 \n",
"17 1 0 0 \n",
"18 1 0 0 \n",
"19 0 1 0 \n",
"20 0 1 0 \n",
"21 0 1 0 \n",
"22 0 1 0 \n",
"23 0 1 0 \n",
"24 0 1 0 \n",
"25 0 1 0 \n",
"26 0 1 0 \n",
"27 0 1 0 \n",
"28 0 1 0 \n",
"29 0 1 0 \n",
"30 0 1 0 \n",
"31 0 1 0 \n",
"32 0 1 0 \n",
"33 0 1 0 \n",
"34 0 1 0 \n",
"35 0 1 0 \n",
"36 0 1 0 \n",
"37 0 1 0 \n",
"38 0 1 0 \n",
"39 0 0 1 \n",
"40 0 0 1 \n",
"41 0 0 1 \n",
"42 0 0 1 \n",
"43 0 0 1 \n",
"44 0 0 1 \n",
"45 0 0 1 \n",
"46 0 0 1 \n",
"47 0 0 1 \n",
"48 0 0 1 \n",
"49 0 0 1 \n",
"50 0 0 1 \n",
"51 0 0 1 \n",
"52 0 0 1 \n",
"53 0 0 1 \n",
"54 0 0 1 \n",
"55 0 0 1 \n",
"56 0 0 1 \n",
"57 0 0 1 \n",
"58 0 0 1 \n",
"\n",
" No_Itching_and_Scratching ... Itching_and_Scratching-constantly \\\n",
"0 1 ... 0 \n",
"1 1 ... 0 \n",
"2 1 ... 0 \n",
"3 1 ... 0 \n",
"4 1 ... 0 \n",
"5 1 ... 0 \n",
"6 1 ... 0 \n",
"7 1 ... 0 \n",
"8 1 ... 0 \n",
"9 1 ... 0 \n",
"10 1 ... 0 \n",
"11 1 ... 0 \n",
"12 1 ... 0 \n",
"13 1 ... 0 \n",
"14 1 ... 0 \n",
"15 1 ... 0 \n",
"16 1 ... 0 \n",
"17 1 ... 0 \n",
"18 1 ... 0 \n",
"19 0 ... 0 \n",
"20 0 ... 0 \n",
"21 0 ... 0 \n",
"22 0 ... 0 \n",
"23 0 ... 0 \n",
"24 0 ... 0 \n",
"25 0 ... 0 \n",
"26 0 ... 0 \n",
"27 0 ... 0 \n",
"28 0 ... 0 \n",
"29 0 ... 0 \n",
"30 0 ... 0 \n",
"31 0 ... 0 \n",
"32 0 ... 0 \n",
"33 0 ... 0 \n",
"34 0 ... 0 \n",
"35 0 ... 0 \n",
"36 0 ... 0 \n",
"37 0 ... 0 \n",
"38 0 ... 0 \n",
"39 0 ... 1 \n",
"40 0 ... 1 \n",
"41 0 ... 1 \n",
"42 0 ... 1 \n",
"43 0 ... 1 \n",
"44 0 ... 1 \n",
"45 0 ... 1 \n",
"46 0 ... 1 \n",
"47 0 ... 1 \n",
"48 0 ... 1 \n",
"49 0 ... 1 \n",
"50 0 ... 1 \n",
"51 0 ... 1 \n",
"52 0 ... 1 \n",
"53 0 ... 1 \n",
"54 0 ... 1 \n",
"55 0 ... 1 \n",
"56 0 ... 1 \n",
"57 0 ... 1 \n",
"58 0 ... 1 \n",
"\n",
" No_Thickened_Skin Thickened_Skin \\\n",
"0 1 0 \n",
"1 1 0 \n",
"2 1 0 \n",
"3 1 0 \n",
"4 1 0 \n",
"5 1 0 \n",
"6 1 0 \n",
"7 1 0 \n",
"8 1 0 \n",
"9 1 0 \n",
"10 1 0 \n",
"11 1 0 \n",
"12 1 0 \n",
"13 1 0 \n",
"14 1 0 \n",
"15 1 0 \n",
"16 1 0 \n",
"17 1 0 \n",
"18 1 0 \n",
"19 0 1 \n",
"20 0 1 \n",
"21 0 1 \n",
"22 0 1 \n",
"23 0 1 \n",
"24 0 1 \n",
"25 0 1 \n",
"26 0 1 \n",
"27 0 1 \n",
"28 0 1 \n",
"29 0 1 \n",
"30 0 1 \n",
"31 0 1 \n",
"32 0 1 \n",
"33 0 1 \n",
"34 0 1 \n",
"35 0 1 \n",
"36 0 1 \n",
"37 0 1 \n",
"38 0 1 \n",
"39 0 0 \n",
"40 0 0 \n",
"41 0 0 \n",
"42 0 0 \n",
"43 0 0 \n",
"44 0 0 \n",
"45 0 0 \n",
"46 0 0 \n",
"47 0 0 \n",
"48 0 0 \n",
"49 0 0 \n",
"50 0 0 \n",
"51 0 0 \n",
"52 0 0 \n",
"53 0 0 \n",
"54 0 0 \n",
"55 0 0 \n",
"56 0 0 \n",
"57 0 0 \n",
"58 0 0 \n",
"\n",
" Extremely_Thickened_Skin(Elephant_skin_appearance) No_Hair_Loss \\\n",
"0 0 1 \n",
"1 0 1 \n",
"2 0 1 \n",
"3 0 1 \n",
"4 0 1 \n",
"5 0 1 \n",
"6 0 1 \n",
"7 0 1 \n",
"8 0 1 \n",
"9 0 1 \n",
"10 0 1 \n",
"11 0 1 \n",
"12 0 1 \n",
"13 0 1 \n",
"14 0 1 \n",
"15 0 1 \n",
"16 0 1 \n",
"17 0 1 \n",
"18 0 1 \n",
"19 0 0 \n",
"20 0 0 \n",
"21 0 0 \n",
"22 0 0 \n",
"23 0 0 \n",
"24 0 0 \n",
"25 0 0 \n",
"26 0 0 \n",
"27 0 0 \n",
"28 0 0 \n",
"29 0 0 \n",
"30 0 0 \n",
"31 0 0 \n",
"32 0 0 \n",
"33 0 0 \n",
"34 0 0 \n",
"35 0 0 \n",
"36 0 0 \n",
"37 0 0 \n",
"38 0 0 \n",
"39 1 0 \n",
"40 1 0 \n",
"41 1 0 \n",
"42 1 0 \n",
"43 1 0 \n",
"44 1 0 \n",
"45 1 0 \n",
"46 1 0 \n",
"47 1 0 \n",
"48 1 0 \n",
"49 1 0 \n",
"50 1 0 \n",
"51 1 0 \n",
"52 1 0 \n",
"53 1 0 \n",
"54 1 0 \n",
"55 1 0 \n",
"56 1 0 \n",
"57 1 0 \n",
"58 1 0 \n",
"\n",
" Starting_Hair_Loss Hair_Loss No_Hearing_Issues Hearing_Issues Deafness \n",
"0 0 0 1 0 0 \n",
"1 0 0 1 0 0 \n",
"2 0 0 1 0 0 \n",
"3 0 0 1 0 0 \n",
"4 0 0 1 0 0 \n",
"5 0 0 1 0 0 \n",
"6 0 0 1 0 0 \n",
"7 0 0 1 0 0 \n",
"8 0 0 1 0 0 \n",
"9 0 0 1 0 0 \n",
"10 0 0 1 0 0 \n",
"11 0 0 1 0 0 \n",
"12 0 0 1 0 0 \n",
"13 0 0 1 0 0 \n",
"14 0 0 1 0 0 \n",
"15 0 0 1 0 0 \n",
"16 0 0 1 0 0 \n",
"17 0 0 1 0 0 \n",
"18 0 0 1 0 0 \n",
"19 1 0 0 1 0 \n",
"20 1 0 0 1 0 \n",
"21 1 0 0 1 0 \n",
"22 1 0 0 1 0 \n",
"23 1 0 0 1 0 \n",
"24 1 0 0 1 0 \n",
"25 1 0 0 1 0 \n",
"26 1 0 0 1 0 \n",
"27 1 0 0 1 0 \n",
"28 1 0 0 1 0 \n",
"29 1 0 0 1 0 \n",
"30 1 0 0 1 0 \n",
"31 1 0 0 1 0 \n",
"32 1 0 0 1 0 \n",
"33 1 0 0 1 0 \n",
"34 1 0 0 1 0 \n",
"35 1 0 0 1 0 \n",
"36 1 0 0 1 0 \n",
"37 1 0 0 1 0 \n",
"38 1 0 0 1 0 \n",
"39 0 1 0 0 1 \n",
"40 0 1 0 0 1 \n",
"41 0 1 0 0 0 \n",
"42 0 1 0 0 1 \n",
"43 0 1 0 0 0 \n",
"44 0 1 0 0 1 \n",
"45 0 1 0 0 0 \n",
"46 0 1 0 0 0 \n",
"47 0 1 0 0 0 \n",
"48 0 1 0 0 1 \n",
"49 0 1 0 0 0 \n",
"50 0 1 0 0 0 \n",
"51 0 1 0 0 0 \n",
"52 0 1 0 0 0 \n",
"53 0 1 0 0 1 \n",
"54 0 1 0 0 1 \n",
"55 0 1 0 0 1 \n",
"56 0 1 0 0 1 \n",
"57 0 1 0 0 1 \n",
"58 0 1 0 0 1 \n",
"\n",
"[59 rows x 21 columns]\n"
]
}
],
"source": [
"X= df[l1]\n",
"y = df[[\"Prediction\"]]\n",
"np.ravel(y)\n",
"print(X)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "7678d75d",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Yeast_Visibility-ears,armpits,_or_paws</th>\n",
" <th>Yeast_Visibility-around_half_of_the_body</th>\n",
" <th>Yeast_Visibility-whole_body</th>\n",
" <th>Redness-pink_or_red_skin</th>\n",
" <th>Redness-red_skin</th>\n",
" <th>Redness-gray_or_black_skin</th>\n",
" <th>No_unpleasant_Smell</th>\n",
" <th>Musty_smell</th>\n",
" <th>Extreme_musty_smell</th>\n",
" <th>No_Itching_and_Scratching</th>\n",
" <th>...</th>\n",
" <th>No_Thickened_Skin</th>\n",
" <th>Thickened_Skin</th>\n",
" <th>Extremely_Thickened_Skin(Elephant_skin_appearance)</th>\n",
" <th>No_Hair_Loss</th>\n",
" <th>Starting_Hair_Loss</th>\n",
" <th>Hair_Loss</th>\n",
" <th>No_Hearing_Issues</th>\n",
" <th>Hearing_Issues</th>\n",
" <th>Deafness</th>\n",
" <th>Prediction</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 22 columns</p>\n",
"</div>"
],
"text/plain": [
" Yeast_Visibility-ears,armpits,_or_paws \\\n",
"0 1 \n",
"1 1 \n",
"2 1 \n",
"3 1 \n",
"4 0 \n",
"\n",
" Yeast_Visibility-around_half_of_the_body Yeast_Visibility-whole_body \\\n",
"0 0 0 \n",
"1 0 0 \n",
"2 0 0 \n",
"3 0 0 \n",
"4 1 0 \n",
"\n",
" Redness-pink_or_red_skin Redness-red_skin Redness-gray_or_black_skin \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 0 1 0 \n",
"\n",
" No_unpleasant_Smell Musty_smell Extreme_musty_smell \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 0 1 0 \n",
"\n",
" No_Itching_and_Scratching ... No_Thickened_Skin Thickened_Skin \\\n",
"0 1 ... 1 0 \n",
"1 1 ... 1 0 \n",
"2 1 ... 1 0 \n",
"3 1 ... 1 0 \n",
"4 0 ... 0 1 \n",
"\n",
" Extremely_Thickened_Skin(Elephant_skin_appearance) No_Hair_Loss \\\n",
"0 0 1 \n",
"1 0 1 \n",
"2 0 1 \n",
"3 0 1 \n",
"4 0 0 \n",
"\n",
" Starting_Hair_Loss Hair_Loss No_Hearing_Issues Hearing_Issues Deafness \\\n",
"0 0 0 1 0 0 \n",
"1 0 0 1 0 0 \n",
"2 0 0 1 0 0 \n",
"3 0 0 1 0 0 \n",
"4 1 0 0 1 0 \n",
"\n",
" Prediction \n",
"0 0 \n",
"1 0 \n",
"2 0 \n",
"3 0 \n",
"4 1 \n",
"\n",
"[5 rows x 22 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Reading the testing.csv file\n",
"tr=pd.read_csv(\"testing.csv\")\n",
"\n",
"tr.replace({'Prediction':{'Primary':0,'Secondary':1,'Tertiary':2}},inplace=True)\n",
"tr.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "1e7a74a7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Yeast_Visibility-ears,armpits,_or_paws \\\n",
"0 1 \n",
"1 1 \n",
"2 1 \n",
"3 1 \n",
"4 0 \n",
"5 0 \n",
"6 0 \n",
"7 0 \n",
"8 0 \n",
"9 0 \n",
"10 0 \n",
"11 0 \n",
"12 0 \n",
"13 0 \n",
"\n",
" Yeast_Visibility-around_half_of_the_body Yeast_Visibility-whole_body \\\n",
"0 0 0 \n",
"1 0 0 \n",
"2 0 0 \n",
"3 0 0 \n",
"4 1 0 \n",
"5 1 0 \n",
"6 1 0 \n",
"7 1 0 \n",
"8 1 0 \n",
"9 0 1 \n",
"10 0 1 \n",
"11 0 1 \n",
"12 0 1 \n",
"13 0 1 \n",
"\n",
" Redness-pink_or_red_skin Redness-red_skin Redness-gray_or_black_skin \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 0 1 0 \n",
"5 0 1 0 \n",
"6 0 1 0 \n",
"7 0 1 0 \n",
"8 0 1 0 \n",
"9 0 0 1 \n",
"10 0 0 1 \n",
"11 0 0 1 \n",
"12 0 0 1 \n",
"13 0 0 1 \n",
"\n",
" No_unpleasant_Smell Musty_smell Extreme_musty_smell \\\n",
"0 1 0 0 \n",
"1 1 0 0 \n",
"2 1 0 0 \n",
"3 1 0 0 \n",
"4 0 1 0 \n",
"5 0 1 0 \n",
"6 0 1 0 \n",
"7 0 1 0 \n",
"8 0 1 0 \n",
"9 0 0 1 \n",
"10 0 0 1 \n",
"11 0 0 1 \n",
"12 0 0 1 \n",
"13 0 0 1 \n",
"\n",
" No_Itching_and_Scratching ... Itching_and_Scratching-constantly \\\n",
"0 1 ... 0 \n",
"1 1 ... 0 \n",
"2 1 ... 0 \n",
"3 1 ... 0 \n",
"4 0 ... 0 \n",
"5 0 ... 0 \n",
"6 0 ... 0 \n",
"7 0 ... 0 \n",
"8 0 ... 0 \n",
"9 0 ... 1 \n",
"10 0 ... 1 \n",
"11 0 ... 1 \n",
"12 0 ... 1 \n",
"13 0 ... 1 \n",
"\n",
" No_Thickened_Skin Thickened_Skin \\\n",
"0 1 0 \n",
"1 1 0 \n",
"2 1 0 \n",
"3 1 0 \n",
"4 0 1 \n",
"5 0 1 \n",
"6 0 1 \n",
"7 0 1 \n",
"8 0 1 \n",
"9 0 0 \n",
"10 0 0 \n",
"11 0 0 \n",
"12 0 0 \n",
"13 0 0 \n",
"\n",
" Extremely_Thickened_Skin(Elephant_skin_appearance) No_Hair_Loss \\\n",
"0 0 1 \n",
"1 0 1 \n",
"2 0 1 \n",
"3 0 1 \n",
"4 0 0 \n",
"5 0 0 \n",
"6 0 0 \n",
"7 0 0 \n",
"8 0 0 \n",
"9 1 0 \n",
"10 1 0 \n",
"11 1 0 \n",
"12 1 0 \n",
"13 1 0 \n",
"\n",
" Starting_Hair_Loss Hair_Loss No_Hearing_Issues Hearing_Issues Deafness \n",
"0 0 0 1 0 0 \n",
"1 0 0 1 0 0 \n",
"2 0 0 1 0 0 \n",
"3 0 0 1 0 0 \n",
"4 1 0 0 1 0 \n",
"5 1 0 0 1 0 \n",
"6 1 0 0 1 0 \n",
"7 1 0 0 1 0 \n",
"8 1 0 0 1 0 \n",
"9 0 1 0 0 1 \n",
"10 0 1 0 0 1 \n",
"11 0 1 0 0 1 \n",
"12 0 1 0 0 1 \n",
"13 0 1 0 0 1 \n",
"\n",
"[14 rows x 21 columns]\n"
]
}
],
"source": [
"X_test= tr[l1]\n",
"y_test = tr[[\"Prediction\"]]\n",
"np.ravel(y_test)\n",
"print(X_test)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a51d07e4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Prediction\n",
"0 0\n",
"1 0\n",
"2 0\n",
"3 0\n",
"4 1\n",
"5 1\n",
"6 1\n",
"7 1\n",
"8 1\n",
"9 2\n",
"10 2\n",
"11 2\n",
"12 2\n",
"13 2\n"
]
}
],
"source": [
"print(y_test)"
]
},
{
"cell_type": "markdown",
"id": "d072b65e",
"metadata": {},
"source": [
"Random Forest Algorithm"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "8c5e9d1f",
"metadata": {},
"outputs": [],
"source": [
"root = Tk()\n",
"pred1=StringVar()\n",
"pred2=StringVar()\n",
"def randomforest():\n",
" if len(NameEn.get()) == 0:\n",
" pred1.set(\" \")\n",
" comp=messagebox.askokcancel(\"System\",\"Please fill the breed of your pet!\")\n",
" if comp:\n",
" root.mainloop()\n",
" elif((Symptom1.get()==\"Select Here\") or (Symptom2.get()==\"Select Here\")):\n",
" pred1.set(\" \")\n",
" sym=messagebox.askokcancel(\"System\",\"Please fill atleast first two Symptoms\")\n",
" if sym:\n",
" root.mainloop()\n",
" else:\n",
" from sklearn.ensemble import RandomForestClassifier\n",
" clf4 = RandomForestClassifier(n_estimators=100)\n",
" clf4 = clf4.fit(X,np.ravel(y))\n",
"\n",
" # calculating accuracy \n",
" from sklearn.metrics import classification_report,confusion_matrix,accuracy_score\n",
" y_pred=clf4.predict(X_test)\n",
" print(\"Random Forest\")\n",
" print(\"Accuracy\")\n",
" print(accuracy_score(y_test, y_pred))\n",
" print(accuracy_score(y_test, y_pred,normalize=False))\n",
" print(\"Confusion matrix\")\n",
" conf_matrix=confusion_matrix(y_test,y_pred)\n",
" print(conf_matrix)\n",
" \n",
" psymptoms = [Symptom1.get(),Symptom2.get(),Symptom3.get(),Symptom4.get(),Symptom5.get(),Symptom6.get(),Symptom7.get()]\n",
"\n",
" for k in range(0,len(l1)):\n",
" for z in psymptoms:\n",
" if(z==l1[k]):\n",
" l2[k]=1\n",
"\n",
" inputtest = [l2]\n",
" predict = clf4.predict(inputtest)\n",
" predicted=predict[0]\n",
" \n",
" h='no'\n",
" for a in range(0,len(level)):\n",
" if(predicted == a):\n",
" h='yes'\n",
" break\n",
" if (h=='yes'):\n",
" pred2.set(\" \")\n",
" pred2.set(level[a])\n",
" else:\n",
" pred2.set(\" \")\n",
" pred2.set(\"Not Found\")"
]
},
{
"cell_type": "markdown",
"id": "3d34149e",
"metadata": {},
"source": [
"Building Graphical User Interface"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "99ed3abf",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"''"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Tk class is used to create a root window\n",
"root.configure(background='Ivory')\n",
"root.title('Skin Disease Severity Level Predictor System')\n",
"root.resizable(0,0)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "54176629",
"metadata": {},
"outputs": [],
"source": [
"Symptom1 = StringVar()\n",
"Symptom1.set(\"Select Here\")\n",
"\n",
"Symptom2 = StringVar()\n",
"Symptom2.set(\"Select Here\")\n",
"\n",
"Symptom3 = StringVar()\n",
"Symptom3.set(\"Select Here\")\n",
"\n",
"Symptom4 = StringVar()\n",
"Symptom4.set(\"Select Here\")\n",
"\n",
"Symptom5 = StringVar()\n",
"Symptom5.set(\"Select Here\")\n",
"\n",
"Symptom6 = StringVar()\n",
"Symptom6.set(\"Select Here\")\n",
"\n",
"Symptom7 = StringVar()\n",
"Symptom7.set(\"Select Here\")\n",
"Name = StringVar()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "4735241e",
"metadata": {},
"outputs": [],
"source": [
"prev_win=None\n",
"def Reset():\n",
" global prev_win\n",
"\n",
" Symptom1.set(\"Select Here\")\n",
" Symptom2.set(\"Select Here\")\n",
" Symptom3.set(\"Select Here\")\n",
" Symptom4.set(\"Select Here\")\n",
" Symptom5.set(\"Select Here\")\n",
" Symptom6.set(\"Select Here\")\n",
" Symptom7.set(\"Select Here\")\n",
" NameEn.delete(first=0,last=100)\n",
" pred1.set(\" \")\n",
" pred2.set(\" \")\n",
" try:\n",
" prev_win.destroy()\n",
" prev_win=None\n",
" except AttributeError:\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c72bac2b",
"metadata": {},
"outputs": [],
"source": [
"from tkinter import messagebox\n",
"def Exit():\n",
" qExit=messagebox.askyesno(\"System\",\"Do you want to exit the system ?\")\n",
" \n",
" if qExit:\n",
" root.destroy()\n",
" exit()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "fc2e6a16",
"metadata": {},
"outputs": [],
"source": [
"#Heading\n",
"w2 = Label(root, justify=LEFT, text=\"Skin Disease Severity Level Prediction\", fg=\"Black\", bg=\"Ivory\")\n",
"w2.config(font=(\"Times\",30,\"bold\"))\n",
"w2.grid(row=1, column=0, columnspan=2, padx=100)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "e08d86c6",
"metadata": {},
"outputs": [],
"source": [
"#Label - breed\n",
"NameLb = Label(root, text=\"Breed of the Pet *\", fg=\"Dark Blue\", bg=\"Ivory\")\n",
"NameLb.config(font=(\"Times\",15,\"bold\"))\n",
"NameLb.grid(row=6, column=0, pady=15, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "7a538310",
"metadata": {},
"outputs": [],
"source": [
"#Labels - symptoms\n",
"S1Lb = Label(root, text=\"Symptom 1 *\", fg=\"Black\", bg=\"Ivory\")\n",
"S1Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S1Lb.grid(row=7, column=0, pady=10, sticky=W)\n",
"\n",
"S2Lb = Label(root, text=\"Symptom 2 *\", fg=\"Black\", bg=\"Ivory\")\n",
"S2Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S2Lb.grid(row=8, column=0, pady=10, sticky=W)\n",
"\n",
"S3Lb = Label(root, text=\"Symptom 3\", fg=\"Black\",bg=\"Ivory\")\n",
"S3Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S3Lb.grid(row=9, column=0, pady=10, sticky=W)\n",
"\n",
"S4Lb = Label(root, text=\"Symptom 4\", fg=\"Black\", bg=\"Ivory\")\n",
"S4Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S4Lb.grid(row=10, column=0, pady=10, sticky=W)\n",
"\n",
"S5Lb = Label(root, text=\"Symptom 5\", fg=\"Black\", bg=\"Ivory\")\n",
"S5Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S5Lb.grid(row=11, column=0, pady=10, sticky=W)\n",
"\n",
"S6Lb = Label(root, text=\"Symptom 6\", fg=\"Black\", bg=\"Ivory\")\n",
"S6Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S6Lb.grid(row=12, column=0, pady=10, sticky=W)\n",
"\n",
"S7Lb = Label(root, text=\"Symptom 7\", fg=\"Black\", bg=\"Ivory\")\n",
"S7Lb.config(font=(\"Times\",15,\"bold\"))\n",
"S7Lb.grid(row=13, column=0, pady=10, sticky=W)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "9c70874c",
"metadata": {},
"outputs": [],
"source": [
"#Labels - algorithm\n",
"destreeLb = Label(root, text=\"RandomForest\", fg=\"black\", bg=\"Light blue\", width = 20)\n",
"destreeLb.config(font=(\"Times\",15,\"bold\"))\n",
"destreeLb.grid(row=15, column=0, pady=10, sticky=W)\n",
"OPTIONS = sorted(l1)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "7046ac08",
"metadata": {},
"outputs": [],
"source": [
"#Taking breed-name as input from user\n",
"NameEn = Entry(root, textvariable=Name)\n",
"NameEn.grid(row=6, column=1)\n",
"\n",
"#Taking Symptoms as input from the dropdown from the user\n",
"S1 = OptionMenu(root, Symptom1,*OPTIONS)\n",
"S1.grid(row=7, column=1)\n",
"\n",
"S2 = OptionMenu(root, Symptom2,*OPTIONS)\n",
"S2.grid(row=8, column=1)\n",
"\n",
"S3 = OptionMenu(root, Symptom3,*OPTIONS)\n",
"S3.grid(row=9, column=1)\n",
"\n",
"S4 = OptionMenu(root, Symptom4,*OPTIONS)\n",
"S4.grid(row=10, column=1)\n",
"\n",
"S5 = OptionMenu(root, Symptom5,*OPTIONS)\n",
"S5.grid(row=11, column=1)\n",
"\n",
"S6 = OptionMenu(root, Symptom6,*OPTIONS)\n",
"S6.grid(row=12, column=1)\n",
"\n",
"S7 = OptionMenu(root, Symptom7,*OPTIONS)\n",
"S7.grid(row=13, column=1)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "fc8a3387",
"metadata": {},
"outputs": [],
"source": [
"#Buttons\n",
"rnf = Button(root, text=\"Prediction\", command=randomforest,bg=\"Blue\",fg=\"yellow\")\n",
"rnf.config(font=(\"Times\",15,\"bold\"))\n",
"rnf.grid(row=6, column=3,padx=10)\n",
"\n",
"rs = Button(root,text=\"Reset Inputs\", command=Reset,bg=\"yellow\",fg=\"purple\",width=12)\n",
"rs.config(font=(\"Times\",15,\"bold\"))\n",
"rs.grid(row=10,column=3,padx=10)\n",
"\n",
"ex = Button(root,text=\"Exit System\", command=Exit,bg=\"yellow\",fg=\"purple\",width=12)\n",
"ex.config(font=(\"Times\",15,\"bold\"))\n",
"ex.grid(row=11,column=3,padx=10)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "6f68b8b5",
"metadata": {},
"outputs": [],
"source": [
"#Showing the output\n",
"t2=Label(root,font=(\"Times\",15,\"bold\"),text=\"Random Forest\",height=1,bg=\"Light green\"\n",
" ,width=40,fg=\"black\",textvariable=pred2,relief=\"sunken\").grid(row=15, column=1, padx=10)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "2e41667b",
"metadata": {},
"outputs": [],
"source": [
"#calling this function\n",
"root.mainloop()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f612b71c",
"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