def get_beta_parameters(confusion):
    """ Extract the beta parameters from a confusion matrix.

        Parameters
        ----------
        confusion : array, shape = [n_classes, n_classes]
            Where entry c_{ij} is the number of observations in class i but
            are classified as class j.

        Returns
        -------
        parameters: array of tuples
            Each tuple (alpha_i, beta_i) is the parameters of a Beta distribution
            that corresponds to class i.
    """

    alphas, betas = [], []

    # number of classes
    k = len(confusion)

    for i in range(k):
        # alpha is 1 plus the number of objects that are correctly classified
        alphas.append(1 + confusion[i, i])

        # beta is 1 plus the number of objects that are incorrectly classified
        betas.append(1 + confusion.sum(axis=1)[i] - confusion[i, i])

    return list(zip(alphas, betas))