mdr/utils/utils.py
def mdr_mutual_information(X, Y, labels, base=2):
    """Calculates the MDR mutual information, I(XY;labels), in the given base

    MDR mutual information is calculated by combining variables X and Y into a single MDR model then calculating
    the mutual information between the resulting model's predictions and the labels.

    Parameters
    ----------
    X: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    Y: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    labels: array-like (# samples)
        The class labels corresponding to features X and Y
    base: integer (default: 2)
        The base in which to calculate MDR mutual information

    Returns
    ----------
    mdr_mutual_information: float
        The MDR mutual information calculated according to the equation I(XY;labels) = H(labels) - H(labels|XY)

    """
    return mutual_information(_mdr_predict(X, Y, labels), labels, base=base)
def mdr_mutual_information(X, Y, labels, base=2):
    """Calculates the MDR mutual information, I(XY;labels), in the given base

    MDR mutual information is calculated by combining variables X and Y into a single MDR model then calculating
    the mutual information between the resulting model's predictions and the labels.

    Parameters
    ----------
    X: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    Y: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    labels: array-like (# samples)
        The class labels corresponding to features X and Y
    base: integer (default: 2)
        The base in which to calculate MDR mutual information

    Returns
    ----------
    mdr_mutual_information: float
        The MDR mutual information calculated according to the equation I(XY;labels) = H(labels) - H(labels|XY)

    """
    return mutual_information(_mdr_predict(X, Y, labels), labels, base=base)
Calculates the MDR mutual information, I(XY;labels), in the given base

    MDR mutual information is calculated by combining variables X and Y into a single MDR model then calculating
    the mutual information between the resulting model's predictions and the labels.

    Parameters
    ----------
    X: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    Y: array-like (# samples)
        An array of values corresponding to one feature in the MDR model
    labels: array-like (# samples)
        The class labels corresponding to features X and Y
    base: integer (default: 2)
        The base in which to calculate MDR mutual information

    Returns
    ----------
    mdr_mutual_information: float
        The MDR mutual information calculated according to the equation I(XY;labels) = H(labels) - H(labels|XY)