:py:mod:`bhepop2.functions` =========================== .. py:module:: bhepop2.functions Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: bhepop2.functions.get_attributes bhepop2.functions.filter_distributions_and_infer_modalities bhepop2.functions.infer_modalities_from_distributions bhepop2.functions.compute_feature_values bhepop2.functions.get_feature_from_qualitative_distribution bhepop2.functions.compute_features_prob bhepop2.functions.interpolate_feature_prob bhepop2.functions.compute_crossed_modalities_frequencies bhepop2.functions.build_cross_table bhepop2.functions.compute_rq .. py:function:: get_attributes(modalities: dict) -> list Get attributes list from dictionary of modalities :param modalities: :return: attributes .. py:function:: filter_distributions_and_infer_modalities(distributions: pandas.DataFrame, attribute_selection) Filter distributions table with attribute selection and infer modalities. :param distributions: distribution DataFrame :param attribute_selection: list of attributes to keep in the distribution, or None :return: filtered distribution Dataframe, { attribute: [modalities] } dict .. py:function:: infer_modalities_from_distributions(distributions: pandas.DataFrame) Infer attributes and their modalities from the given distributions. :param distributions: distributions DataFrame :return: dict of attributes and their modalities, { attribute: [modalities] } .. py:function:: compute_feature_values(distribution: pandas.DataFrame, relative_maximum: float, delta_min=None) -> list Compute the list of feature values that will define the assignment intervals. The distributions do not give the knowledge of the minimum and maximum feature values, so we have to choose them. The minimum is the same for all distributions, it is directly equal to the abs_first_value parameter. The maximum is computed by multiplying the relative_maximum parameter to the last value of each distribution. :param distribution: dataframe of distribution :param relative_maximum: multiplicand applied to compute the last feature value of each distribution :param delta_min: minimum delta between two feature values. None to keep all values. :return: list of feature values .. py:function:: get_feature_from_qualitative_distribution(distribution: pandas.DataFrame) Get feature values from the given distributions. :param distribution: distribution DataFrame :return: list of possible values for the qualitative feature .. py:function:: compute_features_prob(feature_values: list, distribution: list) Create a DataFrame containing probabilities for the given feature values. :param feature_values: list of feature values :param distribution: list of distribution values :return: DataFrame of feature probabilities .. py:function:: interpolate_feature_prob(feature_value: float, distribution: list) Linear interpolation of a feature value probability. First and last distribution values represent minimum and maximum values that can be taken. :param feature_value: value of feature to interpolate :param distribution: feature values for each decile from 0 to 10 :return: probability of being lower than the input feature value .. py:function:: compute_crossed_modalities_frequencies(population: pandas.DataFrame, modalities: dict) -> pandas.DataFrame Compute the frequency of each crossed modality present in the population. Columns other than attributes are removed from the result DataFrame, and a 'probability' column is added. :param population: population DataFrame :param modalities: modalities dict :return: DataFrame of crossed modalities frequencies .. py:function:: build_cross_table(pop: pandas.DataFrame, names_attribute: list) Parameters ---------- pop : DataFrame synthesis population names_attribute: list of two strings name of attribute1 and name of attribute 2 Returns ------- table_percentage : DataFrame proportion of modalities of attribute 2 given attribute 1 .. py:function:: compute_rq(model, nb_modalities, K)