def confusion_matrix(Y_truth, Y_pred):
    """Returns a confusion matrix between expected and predicted Y labels.

    Args:
        Y_truth: An integer array (0-based) on the true classes for each test
        Y_pred : An integer array (0-based) on the classifier's predicted output

    Returns:
        matrix : An NxN confusion matrix

    Try case of perfect prediction (diagonal confusion matrix)
    >>> Y_truth = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9]
    >>> Y_pred  = Y_truth
    >>> confusion_matrix(Y_truth, Y_pred)
    array([[2, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 2, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 2, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 2, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 2, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 2, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 2, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 2, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 2]])

    Try case of off-by-one prediction
    >>> Y_truth = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9]
    >>> Y_pred  = [2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1]
    >>> confusion_matrix(Y_truth, Y_pred)
    array([[0, 2, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 2, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 2, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 2, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 2, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 2, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 2, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 2],
           [2, 0, 0, 0, 0, 0, 0, 0, 0]])
    """
    from sklearn.metrics import confusion_matrix as sk_conf_matrix
    return sk_conf_matrix(Y_truth, Y_pred)
