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 program call FancyMyName which asks you to write a program that tests the usage...
Write a program call FancyMyName which asks you to write a program that tests the usage of different methods for working with Strings. This program will ask the user to enter their first name and their last name, separated by a space. Read the user's response using Scanner. Separate the input string up into two strings, one containing the first name and one containing the last name. You can accomplish this by using the indexOf() hint*** find the position of...
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?
In c++ please. Write a program that reads the contents of two text files and compares...
In c++ please. Write a program that reads the contents of two text files and compares them in the following ways: It should display a list of all the unique words contained in both files. It should display a list of the words that appears in both files. It should display a list of the words that appears in the first file, but not the second. It should display a list of the words that appears in the second file,...
ou must write tests for the following: You must write tests for the following (which may...
ou must write tests for the following: You must write tests for the following (which may include Custom Exceptions): BankAccount Class Tests are written such that any deposit that is made greater than 10000 is not accepted. Tests are written such that balance in the BankAccount does not go below 0. Care should be taken for above tests at the time of Initial Deposit and at the time of Withdrawal and future Deposits. Tests should be written such that the...
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
Write a program to receive a string from the user and compares the first and second...
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 halves of...
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...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT