src/bayesian_network.py
def predict_from_data(self, samples_file_name: str):
        """
        This function will predict diseases from symptoms using a given dataset with an expected structure.
        The dataset structure must be in the format of symptoms in columns 0 to last-1 and diseases in the last column.
        :param samples_file_name: the name of the csv_file in the csv folder
        :return: None
        """
        program_start_before_input = default_timer()
        samples = pandas.read_csv(
            f"../csv/{samples_file_name}.csv", delimiter=",", header=None
        )
        program_end_before_input = default_timer()
        user_symptoms = self.__get_symptoms_from_user(samples)
        program_start_after_input = default_timer()
        number_symptoms = samples.shape[1] - 1  # number columns in samples
        model_start_time = default_timer()
        model = BayesianNetwork.from_samples(
            X=samples.values,
            include_edges=[
                (symptom, number_symptoms) for symptom in range(number_symptoms)
            ],
            exclude_edges=(
                list(
                    itertools.combinations(
                        [symptom for symptom in range(number_symptoms)],
                        2,
                    )
                )
            ),
        )
        model.bake()
        model_end_time = default_timer()
        print(
            f"Model finished construction in {model_end_time - model_start_time} seconds"
        )
        predicted_disease = model.predict([user_symptoms])[0]
        prediction_probability = model.probability([predicted_disease])
        print(
            f"The predicted disease is {predicted_disease[-1]} with probability of {prediction_probability}"
        )
        program_end_after_input = default_timer()
        full_program_runtime = (
            program_end_before_input - program_start_before_input
        ) + (program_end_after_input - program_start_after_input)
        print(
            f"The Bayes's Net implementation completed in {full_program_runtime} seconds"
        )

        This function will predict diseases from symptoms using a given dataset with an expected structure.
        The dataset structure must be in the format of symptoms in columns 0 to last-1 and diseases in the last column.
        :param samples_file_name: the name of the csv_file in the csv folder
        :return: None
        
This function will predict diseases from symptoms using a given dataset with an expected structure.
The dataset structure must be in the format of symptoms in columns 0 to last-1 and diseases in the last column.
This function will predict diseases from symptoms using a given dataset with an expected structure . The dataset structure must be in the format of symptoms in columns 0 to last - 1 and diseases in the last column .
def predict_from_data(self, samples_file_name: str):
        program_start_before_input = default_timer()
        samples = pandas.read_csv(
            f"../csv/{samples_file_name}.csv", delimiter=",", header=None
        )
        program_end_before_input = default_timer()
        user_symptoms = self.__get_symptoms_from_user(samples)
        program_start_after_input = default_timer()
        number_symptoms = samples.shape[1] - 1  
        model_start_time = default_timer()
        model = BayesianNetwork.from_samples(
            X=samples.values,
            include_edges=[
                (symptom, number_symptoms) for symptom in range(number_symptoms)
            ],
            exclude_edges=(
                list(
                    itertools.combinations(
                        [symptom for symptom in range(number_symptoms)],
                        2,
                    )
                )
            ),
        )
        model.bake()
        model_end_time = default_timer()
        print(
            f"Model finished construction in {model_end_time - model_start_time} seconds"
        )
        predicted_disease = model.predict([user_symptoms])[0]
        prediction_probability = model.probability([predicted_disease])
        print(
            f"The predicted disease is {predicted_disease[-1]} with probability of {prediction_probability}"
        )
        program_end_after_input = default_timer()
        full_program_runtime = (
            program_end_before_input - program_start_before_input
        ) + (program_end_after_input - program_start_after_input)
        print(
            f"The Bayes's Net implementation completed in {full_program_runtime} seconds"
        )
def predict_from_data ( self , samples_file_name : str ) : program_start_before_input = default_timer ( ) samples = pandas . read_csv ( f"../csv/{samples_file_name}.csv" , delimiter = "," , header = None ) program_end_before_input = default_timer ( ) user_symptoms = self . __get_symptoms_from_user ( samples ) program_start_after_input = default_timer ( ) number_symptoms = samples . shape [ 1 ] - 1 model_start_time = default_timer ( ) model = BayesianNetwork . from_samples ( X = samples . values , include_edges = [ ( symptom , number_symptoms ) for symptom in range ( number_symptoms ) ] , exclude_edges = ( list ( itertools . combinations ( [ symptom for symptom in range ( number_symptoms ) ] , 2 , ) ) ) , ) model . bake ( ) model_end_time = default_timer ( ) print ( f"Model finished construction in {model_end_time - model_start_time} seconds" ) predicted_disease = model . predict ( [ user_symptoms ] ) [ 0 ] prediction_probability = model . probability ( [ predicted_disease ] ) print ( f"The predicted disease is {predicted_disease[-1]} with probability of {prediction_probability}" ) program_end_after_input = default_timer ( ) full_program_runtime = ( program_end_before_input - program_start_before_input ) + ( program_end_after_input - program_start_after_input ) print ( f"The Bayes's Net implementation completed in {full_program_runtime} seconds" )
This function will predict diseases from symptoms using a given dataset with an expected structure.
This function will predict diseases from symptoms using a given dataset with an expected structure .
"""
        This function will predict diseases from symptoms using a given dataset with an expected structure.
        The dataset structure must be in the format of symptoms in columns 0 to last-1 and diseases in the last column.
        :param samples_file_name: the name of the csv_file in the csv folder
        :return: None
        """ # number columns in samples
None
self
samples_file_name
str
the name of the csv_file in the csv folder
the name of the csv_file in the csv folder