Skip to content

Score Functions - Categorical Kernels

Categorical score kernels used by the score module. They were extracted into this sibling module so that causaliq_data.score stays within the module size limits described in the development policy. Every name is re-exported from causaliq_data.score, so import paths are unchanged.

Bayesian Scores

bayesian_score

bayesian_score(N_ijk: ndarray, q_i: int, type: str, params: Dict[str, Any]) -> float

Return Bayesian based scores for marginal counts (for a node).

Variable names follow standard names used for the relevant formula in the literature.

Parameters:

  • N_ijk

    (ndarray) –

    2-D array of instance counts for node i, parental combo j and node value k.

  • q_i

    (int) –

    Maximum possible number of parental value combinations (even if they don't all necessarily occur in the data).

  • type

    (str) –

    Bayesian score type required e.g. bde, k2.

  • params

    (dict) –

    Parameters used in score computation: 'base' is logarithm base.

Returns:

  • dict ( float ) –

    Of requested scores {score: value}.

Raises:

  • TypeError –

    If any argument has invalid type.

  • ValueError –

    If any argument has invalid value.

Entropy Scores

entropy_scores

entropy_scores(
    Nijk: ndarray,
    types: Union[str, List[str]],
    params: Dict[str, Any],
    N: int,
    free_params: int,
) -> Dict[str, float]

Return entropy based scores for marginal counts (for a node).

Parameters:

  • Nijk

    (ndarray) –

    2-D array of instance counts for node i, parental combo j and node value k.

  • types

    (str / list) –

    Entropy based score(s) required.

  • params

    (dict) –

    Parameters used in score computation: 'base' is logarithm base.

  • N

    (int) –

    Number of cases (instances).

  • free_params

    (int) –

    Number of free parameters.

Returns:

  • dict ( Dict[str, float] ) –

    Of requested scores {score: value}.

Raises:

  • TypeError –

    If any argument has invalid type.

  • ValueError –

    If any argument has invalid value.