def kappa_statistic(self):
if self.population() == <NUM_LIT:0>:<EOL><INDENT>return float('<STR_LIT>')<EOL><DEDENT>random_accuracy = (<EOL>(self._tn + self._fp) * (self._tn + self._fn)<EOL>+ (self._fn + self._tp) * (self._fp + self._tp)<EOL>) / self.population() ** <NUM_LIT:2><EOL>return (self.accuracy() - random_accuracy) / (<NUM_LIT:1> - random_accuracy)<EOL>
r"""Return κ statistic.

        The κ statistic is defined as:
        :math:`\kappa = \frac{accuracy - random~ accuracy}
        {1 - random~ accuracy}`

        The κ statistic compares the performance of the classifier relative to
        the performance of a random classifier. :math:`\kappa` = 0 indicates
        performance identical to random. :math:`\kappa` = 1 indicates perfect
        predictive success. :math:`\kappa` = -1 indicates perfect predictive
        failure.

        Returns
        -------
        float
            The κ statistic of the confusion table

        Example
        -------
        >>> ct = ConfusionTable(120, 60, 20, 30)
        >>> ct.kappa_statistic()
        0.5344129554655871