Write a python program for thefollowing question.
Complete the symptom similarity function, which measures thesimilarity between the symptoms of two patients.See below for an explanation of how the similarity is computed.
def symptom_similarity(symptoms_A: Tuple[Set],symptoms_B: Tuple[Set]) -> int:
'''Returns the similarity between symptoms_A andsymptoms_B.
symptoms_A and symptoms_B are tuples of a set of symptoms presentand a set of symptoms absent.
The similarity measure is computed by the followingequations:
present_present + absent_absent - present_absent -absent_present
where:
present_present is the number of symptoms present inboth patients
absent_absent is the number of symptoms absent inboth patients
present_absent is the number of symptoms present inpatientA and absent in patientB
absent_present is the number of symptoms absent inpatientA and present in patientB.
>>>symptom_similarity(yang, maria)
1
#yang = ({\"coughing\", \"runny_nose\",\"sneezing\"},{\"headache\",\"fever\"})
#maria = ({\"coughing\", \"fever\", \"sore_throat\",\"sneezing\"},{\"muscle_pain\"}
# As you can see the common part in these two tuple is \"coughing'so similarity is 1.
''''
Question 2: similarity to patients (18points)
Complete the similarity to patients function, which uses thefunction symptom similarity to select
the patients (from the entire population of patients in ourdatabase) with the highest similarity between
the their symptoms and the symptoms of one patient. See below foran explanation of exactly what is
expected:
def similarity_to_patients(my_symptoms : Tuple[Set],all_patients: Dict[str, Tuple[Set]]) ->
Set[int]:
\"\"\"
returns a set of the patient IDs with the highest similaritybetween my_symptoms
(which is a tuple of symptoms present and absent) and the symptomsof
all the patients stored in the dictionary all_patients.
>>> similarity_to_patients(yang,all_patients_symptoms)
{45437, 73454}
#PATIENTS ARE ASSIGNED ID and those ID stores theirsymptoms. So we need to compare \"yang's\" symptoms to other patientssymptoms in the database.
\"\"\"
I will drop a like for even attempting to give a fruitfulsolution.