In: Computer Science
You will write a program in Scheme which compares the accuracy of two medical tests for diagnosing a particular disease.
The input to your program will be a list of data about a collection of patients specifying
The input format will be a sequence of entries of this form:
For example, the list
1 0 0 0 2 1 1 0 3 1 1 1
def predict_accuracy(input_list):
correct_test1 = 0
correct_test2 = 0
no_of_patients = 0
for i in range(0,len(input_list),4):
#first index is leaved as it is for serial no. of patient.
if(input_list[i+1]==1):
#if a patient has a disease then both the test results should be
positive(1) otherwise the tests are considered as wrong.
if(input_list[i+2]==1):
correct_test1 += 1
if(input_list[i+3]==1):
correct_test2 += 1
else:
#if a patient doesn't have disease then both the test result should
be negative(0) only when the test is right.
if(input_list[i+2]==0):
correct_test1 += 1
if(input_list[i+3]==0):
correct_test2 += 1
#Basically finding the no. of patients as each patient will take 4
space in list
no_of_patients = len(input_list)/4
#Finding the percentage accuracy of the tests.
test1_accuracy = (correct_test1/no_of_patients)*100
test2_accuracy = (correct_test2/no_of_patients)*100
#Comparing the accuracies.
if(test1_accuracy>test2_accuracy):
print("Test 1 is ", test1_accuracy - test2_accuracy,"% more
accurate than Test 2")
elif(test2_accuracy>test1_accuracy):
print("Test 2 is ", test2_accuracy - test1_accuracy,"% more
accurate than Test 1")
else:
print("Both the tests are equally accurate")
choice = 'yes'
patient_list = []
patient_count = 0
#Entering the data in the list.
while(choice=='yes' or choice=='Yes'):
patient_count += 1
patient_list.append(patient_count)
print("Enter the detail of patient")
patient_list.append(int(input("Whether Patient have disease if yes
enter 1 otherwise enter 0:")))
patient_list.append(int(input("Enter the test 1 resutl 0 for
negative and 1 for positive:")))
patient_list.append(int(input("Enter the test 2 result 0 for
negative and 1 for positive:")))
choice = input("Do you wants to add more patient
details(Yes/yes/no/No):")
#Calling the predict_accuracy function for comparing the accuracy
of the two tests.
predict_accuracy(patient_list)