Question

In: Computer Science

You will write a program in Scheme which compares the accuracy of two medical tests for...

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

  • Whether the patient has the disease
  • Whether the result of test 1 was positive
  • Whether the result of test 2 was positive

The input format will be a sequence of entries of this form:

  • A positive integer, which is the number of the patient. Patients will be numbered in increasing consecutive order, starting at 1.
  • The number 1 or 0: 1 if the patient has the disease, and 0 if the patient does not have the disease
  • The number 1 or 0: 1 if the patient tested positive on test 1, and 0 of the patient tested negative on test 1
  • The number 1 or 0: 1 if the patient tested positive on test 2, and 0 of the patient tested negative on test 2

For example, the list

   1 0 0 0
   2 1 1 0
   3 1 1 1

Solutions

Expert Solution

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)


Related Solutions

Write a JAVA program that compares two strings input to see if they are the same?
Write a JAVA program that compares two strings input to see if they are the same?
Scheme Programming - Racket R5RS Longest Non-Decreasing Subsequence You will write two Scheme functions that compute...
Scheme Programming - Racket R5RS Longest Non-Decreasing Subsequence You will write two Scheme functions that compute a longest non-decreasing subsequence from a list of numbers. For example, if you type > (lis '(1 2 3 2 4 1 2)) you might get (1 2 3 4) Note that there may be more than one longest non-decreasing subsequence. In the above example, your program might also find (1 2 2 4) or (1 2 2 2). You should concentrate first on...
write a program that gets four digits from the user and tests to see which digit...
write a program that gets four digits from the user and tests to see which digit is the biggest and which is the smallest, use single-alternative only sample output is below: enter four digits and i will tell you which is biggest and smallest: 4 6 7 9 the biggest is 9 the smallest is 4
Question 1: Write a program to receive a string from the user and compares the first...
Question 1: Write a program to receive a string from the user and compares the first and second half of the word and prints “First and Second Half Same” or “First and Second Half Different”. If the length of the word is odd, ignore the middle letter. For example: Run 1: Enter a word: abcdabc First and Second Half Same Run 2: Enter a word: abcde First and Second Half Different Hint: use the Math.floor() and length() to get the...
scheme: Write a recursive Scheme function (subst x y L), which returns a list identical to...
scheme: Write a recursive Scheme function (subst x y L), which returns a list identical to L except that every occurrence of x has been replaced with y. The following example illustrates the use of this function: > (subst 'c 'k '(c o c o n u t)) (k o k o n u t) Write a recursive Scheme function (all-different? L), which determines whether all elements of list L are distinct (that is, not equal?). The following example illustrates...
Program Specifications: Write a program that defines a class HumanBMI, implements it as required, and tests...
Program Specifications: Write a program that defines a class HumanBMI, implements it as required, and tests the class implementation. The class definition and implementation should be separated into HumanBMI.h and HumanBMI.cpp files. A. The class HumanBMI consists of three private member variables: name of type string, height of type int in inches, and weight of type int in pounds. The class HumanBMI also includes the following public member functions: 1) setName to set the name member variable with a string...
You must write each of the following scheme functions. You must use only basic scheme functions...
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. Write a function (merge-sorter L1) that takes list-of-integers L1 and returns all elements of L1 in sorted order. You must use a merge-sort technique that, in the recursive case, a) splits L1 into two approximately-equal-length lists, b) sorts those lists, and then c) merges the...
You must write each of the following scheme functions. You must use only basic scheme functions...
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. This problem need to use DrRacket software. Racket Language. Write a function named (forget-n L1 N) that returns the elements of L1 except for the first N. If N is negative, return all elements. If N exceeds the length of L1 return the empty list....
You must write each of the following scheme functions. You must use only basic scheme functions...
You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. This problem needs to use DrRacket software. Racket Language. Write a function (indices L1 X) that takes a list of elements L1 and an element X. The function returns a list of the indices in L1 that contain X. See the following examples for clarification....
You must write each of the following scheme functions. You must use only basic scheme functions,...
You must write each of the following scheme functions. You must use only basic scheme functions, do not use third-party libraries to support any of your work. Do not use any function with side effects. This problem need to use DrRacket software. Racket Language. Write a function named (first-n L1 N) that returns the first N elements of L1. If N is negative, return the empty list. If N exceeds the length of L1 return all elements of L1. (first-n...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT