import unittest
import pandas as pd
import eval_classification

# Type nosetests in commandline in project root to run these tests.
class TestEvalClassification(unittest.TestCase):

    def setUp(self):
        dict  = {"truth": [1,2,1,1],
                 "predicted": [1,1,1,2],
                 "confidence": [0.2,0.3,0.5,0.5]}
        self.df = pd.DataFrame(dict)

    # # Should see one passing test
    # def test_tests(self):
    #     self.assertEqual(1+1,2)

    # def test_example(self):
    #     self.assertEqual(1.0,1)
    #     self.assertAlmostEqual(1.000000001,1.000000002)
    #
    #
    def test_eval_classification(self):
        self.df.columns.contains("truth")
        self.df.columns.contains("predicted")
        self.df.columns.contains("confidence")
        rates=eval_classification.compare_thresholds(self.df, "truth", "predicted",
                        "confidence",0.4)
        #self.assertEqual(rates,(1,0,0))
        self.assertEqual(rates,
                         {"correct_classified_rate" : 0.25,
                            "misclassified_rate" : 0.25,
                            "not_confident_rate" : 0.5})

@@ -227,17 +227,17 @@
 %22: %5B1,2,
-1
+2
 ,1%5D,%0A   
@@ -268,17 +268,17 @@
 %22: %5B1,1,
-1
+2
 ,2%5D,%0A   
@@ -769,16 +769,54 @@
 idence%22)
+%0A%0A        # If confidence cutoff is .5
 %0A       
@@ -1116,32 +1116,32 @@
 d_rate%22 : 0.25,%0A
-
                 
@@ -1181,8 +1181,1056 @@
 : 0.5%7D)%0A
+%0A        #as we decrease required confidence, we expect decrease in non_confident%0A        # and possible increase of misclassified or correct classified%0A        rates=eval_classification.compare_thresholds(self.df, %22truth%22, %22predicted%22,%0A                        %22confidence%22,0.3)%0A        #self.assertEqual(rates,(1,0,0))%0A        self.assertEqual(rates,%0A                         %7B%22correct_classified_rate%22 : 0.25,%0A                            %22misclassified_rate%22 : 0.5,%0A                            %22not_confident_rate%22 : 0.25%7D)%0A%0A        #further decrease required confidence, further decrease in non_confident%0A        # and possible increase of misclassified or correct classified%0A        rates=eval_classification.compare_thresholds(self.df, %22truth%22, %22predicted%22,%0A                        %22confidence%22,0.2)%0A        #self.assertEqual(rates,(1,0,0))%0A        self.assertEqual(rates,%0A                         %7B%22correct_classified_rate%22 : 0.5,%0A                            %22misclassified_rate%22 : 0.5,%0A                            %22not_confident_rate%22 : 0%7D)%0A

add more tests