src/bayesian_network.py
def predict_with_known_dataset(self):
        """
        This function will predict diseases from symptoms using a known dataset and known structure.
        :return: None
        """
        known_symptoms = get_from_csv("Symptom Probability Tables")
        user_symptoms = self.__get_known_symptoms(known_symptoms)
        (
            symptom_distributions,
            symptom_states,
        ) = self.__get_symptom_distributions_and_states(known_symptoms)
        bayesian_networks_of_diseases = list()
        for disease in [
            "Acne",
            "Allergy",
            "Chicken Pox",
            "Common Cold",
            "Drug Reaction",
            "Psoriasis",
        ]:
            bayesian_networks_of_diseases.append(
                self.__get_bayesian_network_model(
                    symptom_distributions=symptom_distributions,
                    symptom_states=symptom_states,
                    file_name=f"{disease} Full Conditional Probability Table",
                    disease_name=disease,
                )
            )
        prediction_results = dict()
        for bayes_net in bayesian_networks_of_diseases:
            symptoms_and_disease_to_predict = list()
            for s in user_symptoms.values():
                symptoms_and_disease_to_predict.append(
                    f"{s}"  # Requires string per API
                )
            symptoms_and_disease_to_predict.append(
                "1"  # Predict the disease as present
            )
            prediction_results[bayes_net.name] = bayes_net.probability(
                [symptoms_and_disease_to_predict]
            )
        print(
            "Top 3 predicted diseases are (disease, probability):",
            sorted(
                prediction_results.items(), key=operator.itemgetter(1), reverse=True
            )[:3],
        )

        This function will predict diseases from symptoms using a known dataset and known structure.
        :return: None
        
This function will predict diseases from symptoms using a known dataset and known structure.
This function will predict diseases from symptoms using a known dataset and known structure .
def predict_with_known_dataset(self):
        known_symptoms = get_from_csv("Symptom Probability Tables")
        user_symptoms = self.__get_known_symptoms(known_symptoms)
        (
            symptom_distributions,
            symptom_states,
        ) = self.__get_symptom_distributions_and_states(known_symptoms)
        bayesian_networks_of_diseases = list()
        for disease in [
            "Acne",
            "Allergy",
            "Chicken Pox",
            "Common Cold",
            "Drug Reaction",
            "Psoriasis",
        ]:
            bayesian_networks_of_diseases.append(
                self.__get_bayesian_network_model(
                    symptom_distributions=symptom_distributions,
                    symptom_states=symptom_states,
                    file_name=f"{disease} Full Conditional Probability Table",
                    disease_name=disease,
                )
            )
        prediction_results = dict()
        for bayes_net in bayesian_networks_of_diseases:
            symptoms_and_disease_to_predict = list()
            for s in user_symptoms.values():
                symptoms_and_disease_to_predict.append(
                    f"{s}"  
                )
            symptoms_and_disease_to_predict.append(
                "1"  
            )
            prediction_results[bayes_net.name] = bayes_net.probability(
                [symptoms_and_disease_to_predict]
            )
        print(
            "Top 3 predicted diseases are (disease, probability):",
            sorted(
                prediction_results.items(), key=operator.itemgetter(1), reverse=True
            )[:3],
        )
def predict_with_known_dataset ( self ) : known_symptoms = get_from_csv ( "Symptom Probability Tables" ) user_symptoms = self . __get_known_symptoms ( known_symptoms ) ( symptom_distributions , symptom_states , ) = self . __get_symptom_distributions_and_states ( known_symptoms ) bayesian_networks_of_diseases = list ( ) for disease in [ "Acne" , "Allergy" , "Chicken Pox" , "Common Cold" , "Drug Reaction" , "Psoriasis" , ] : bayesian_networks_of_diseases . append ( self . __get_bayesian_network_model ( symptom_distributions = symptom_distributions , symptom_states = symptom_states , file_name = f"{disease} Full Conditional Probability Table" , disease_name = disease , ) ) prediction_results = dict ( ) for bayes_net in bayesian_networks_of_diseases : symptoms_and_disease_to_predict = list ( ) for s in user_symptoms . values ( ) : symptoms_and_disease_to_predict . append ( f"{s}" ) symptoms_and_disease_to_predict . append ( "1" ) prediction_results [ bayes_net . name ] = bayes_net . probability ( [ symptoms_and_disease_to_predict ] ) print ( "Top 3 predicted diseases are (disease, probability):" , sorted ( prediction_results . items ( ) , key = operator . itemgetter ( 1 ) , reverse = True ) [ : 3 ] , )
This function will predict diseases from symptoms using a known dataset and known structure.
This function will predict diseases from symptoms using a known dataset and known structure .
"""
        This function will predict diseases from symptoms using a known dataset and known structure.
        :return: None
        """ # Requires string per API # Predict the disease as present
None
self