def test_roc():
    'Tests the ROC class'

    def checkme(y_true, y_pred, expected_auc):
        'Tests the ROC for a single set of predictions. Mostly sanity checks since all the computation is done\n        by scikit, which we assume is correct'
        roc = ROC.from_scores(y_true, y_pred)
        nose.tools.assert_almost_equal(roc.auc, expected_auc)
        nose.tools.ok_(all(((0 <= fpr_val <= 1) for fpr_val in roc.fpr)))
        nose.tools.ok_(all(((0 <= tpr_val <= 1) for tpr_val in roc.tpr)))
        nose.tools.assert_list_equal(list(roc.dataframe['tpr']), list(roc.tpr))
        nose.tools.assert_list_equal(list(roc.dataframe['thresholds']), list(roc.thresholds))
        for prop in ['fpr', 'tpr', 'thresholds']:
            nose.tools.assert_list_equal(list(roc.dataframe[prop]), list(getattr(roc, prop)))
            nose.tools.assert_greater_equal(len(roc.dataframe[prop]), 2)
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], 1.0))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], 0.0))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], 0.5))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0, 0], 0.75))
Tests the ROC class
def test_roc():
    

    def checkme(y_true, y_pred, expected_auc):
        'Tests the ROC for a single set of predictions. Mostly sanity checks since all the computation is done\n        by scikit, which we assume is correct'
        roc = ROC.from_scores(y_true, y_pred)
        nose.tools.assert_almost_equal(roc.auc, expected_auc)
        nose.tools.ok_(all(((0 <= fpr_val <= 1) for fpr_val in roc.fpr)))
        nose.tools.ok_(all(((0 <= tpr_val <= 1) for tpr_val in roc.tpr)))
        nose.tools.assert_list_equal(list(roc.dataframe['tpr']), list(roc.tpr))
        nose.tools.assert_list_equal(list(roc.dataframe['thresholds']), list(roc.thresholds))
        for prop in ['fpr', 'tpr', 'thresholds']:
            nose.tools.assert_list_equal(list(roc.dataframe[prop]), list(getattr(roc, prop)))
            nose.tools.assert_greater_equal(len(roc.dataframe[prop]), 2)
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], 1.0))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], 0.0))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], 0.5))
    (yield (checkme, [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 1, 0, 0, 0], 0.75))