HI All,
See the code...
The input is trainingdata.csv with the following content
high-temparature headache cough,fever
chest-pain high-pressure breathing-issue,heartattack
very-high-esr faint high-beta-count,cancer
-------------------------------------
import csv
list1=[]
class1=[]
stopwords="i am you we an in on where is are what which here"
slist=stopwords.split()
csvinput=open("trainingdata.csv","r")
reader=csv.reader(csvinput,delimiter=",")
for sym,label in reader:
list1.append(sym)
class1.append(label)
print(list1)
print(class1)
in1=input("Enter your symptoms")
inlist=in1.split()
newlist=list(set(inlist)-set(slist))
print(newlist)
j=0
for i in list1:
#print(i)
templist=i.split()
commonlist=list(set(templist)&set(newlist))
l1=len(commonlist)
percentage=l1/len(templist)*100
#print(templist)
print(class1[j],percentage)
j=j+1
See the code...
The input is trainingdata.csv with the following content
high-temparature headache cough,fever
chest-pain high-pressure breathing-issue,heartattack
very-high-esr faint high-beta-count,cancer
-------------------------------------
import csv
list1=[]
class1=[]
stopwords="i am you we an in on where is are what which here"
slist=stopwords.split()
csvinput=open("trainingdata.csv","r")
reader=csv.reader(csvinput,delimiter=",")
for sym,label in reader:
list1.append(sym)
class1.append(label)
print(list1)
print(class1)
in1=input("Enter your symptoms")
inlist=in1.split()
newlist=list(set(inlist)-set(slist))
print(newlist)
j=0
for i in list1:
#print(i)
templist=i.split()
commonlist=list(set(templist)&set(newlist))
l1=len(commonlist)
percentage=l1/len(templist)*100
#print(templist)
print(class1[j],percentage)
j=j+1
No comments:
Post a Comment