def get_accuracy(n):
    """
    Get the accuracy from a confusion matrix n.

    The mean accuracy is calculated as

    .. math::

        t_i &= \\sum_{j=1}^k n_{ij}\\\\
        acc(n) &= \\frac{\\sum_{i=1}^k n_{ii}}{\\sum_{i=1}^k n_{ii}}

    Parameters
    ----------
    n : dict
        Confusion matrix which has integer keys 0, ..., nb_classes - 1;
        an entry n[i][j] is the count how often class i was classified as
        class j.

    Returns
    -------
    float
        accuracy (in [0, 1])

    References
    ----------
    .. [1] Martin Thoma (2016): A Survey of Semantic Segmentation,
       http://arxiv.org/abs/1602.06541

    Examples
    --------
    >>> n = {0: {0: 10, 1: 2}, 1: {0: 5, 1: 83}}
    >>> get_accuracy(n)
    0.93
    """
    return float(n[0][0] + n[1][1]) / (n[0][0] + n[1][1] + n[0][1] + n[1][0])
