@classmethod<EOL><INDENT>def from_existing(cls, confusion, *args, **kwargs):<DEDENT>
<EOL>df = []<EOL>for t, p in product(confusion.index.values, confusion.columns.values):<EOL><INDENT>df += [[t, p]] * confusion[p][t]<EOL><DEDENT>if confusion.index.name is not None and confusion.columns.name is not None:<EOL><INDENT>return Confusion(pd.DataFrame(df, columns=[confusion.index.name, confusion.columns.name]))<EOL><DEDENT>return Confusion(pd.DataFrame(df))<EOL>
Creates a confusion matrix from a DataFrame that already contains confusion counts (but not meta stats)
        >>> df = pd.DataFrame(np.matrix([[0,1,2,0,1,2,1,2,2,1],[0,1,2,1,2,0,0,1,2,0]]).T, columns=['True', 'Pred'])
        >>> c = Confusion(df)
        >>> c2 = pd.DataFrame(c)
        >>> hasattr(c2, '_binary_sensitivity')
        False
        >>> c3 = Confusion.from_existing(c2)
        >>> hasattr(c3, '_binary_sensitivity')
        True
        >>> (c3 == c).all().all()
        True
        >>> c3
        Pred  0  1  2
        True
        0     1  1  0
        1     2  1  1
        2     1  1  2