def testCalculateAccuracyMixedSamples(self):
        """
    Tests testCalculateAccuracy() method of classification model base class for
    test samples with mixed classifications.
    """
        model = ClassificationModel()

        actualLabels = [numpy.array([0, 1, 2])]
        predictedLabels1 = [numpy.array([1, 2, 0])]
        predictedLabels2 = [numpy.array([1])]
        predictedLabels3 = [None]
        classifications1 = [predictedLabels1, actualLabels]
        classifications2 = [predictedLabels2, actualLabels]
        classifications3 = [predictedLabels3, actualLabels]

        self.assertAlmostEqual(model.calculateAccuracy(classifications1), 1.0)
        self.assertAlmostEqual(model.calculateAccuracy(classifications2), float(1) / 3)
        self.assertAlmostEqual(model.calculateAccuracy(classifications3), 0.0)
    def testCalculateAccuracyMixedSamples(self):
        """
    Tests testCalculateAccuracy() method of classification model base class for
    test samples with mixed classifications.
    """
        model = ClassificationModel()

        actualLabels = [numpy.array([0, 1, 2])]
        predictedLabels1 = [numpy.array([1, 2, 0])]
        predictedLabels2 = [numpy.array([1])]
        predictedLabels3 = [None]
        classifications1 = [predictedLabels1, actualLabels]
        classifications2 = [predictedLabels2, actualLabels]
        classifications3 = [predictedLabels3, actualLabels]

        self.assertAlmostEqual(model.calculateAccuracy(classifications1), 1.0)
        self.assertAlmostEqual(model.calculateAccuracy(classifications2),
                               float(1) / 3)
        self.assertAlmostEqual(model.calculateAccuracy(classifications3), 0.0)
    def testCalculateAccuracyMultipleSamples(self):
        """
    Tests testCalculateAccuracy() method of classification model base class for
    three test samples.
    """
        model = ClassificationModel()

        actualLabels = [numpy.array([0]), numpy.array([0, 2]), numpy.array([0, 1, 2])]
        predictedLabels = [numpy.array([0]), [None], numpy.array([1, 2, 0])]
        classifications = [predictedLabels, actualLabels]

        self.assertAlmostEqual(model.calculateAccuracy(classifications), float(2) / 3)
    def testCalculateAccuracyMultipleSamples(self):
        """
    Tests testCalculateAccuracy() method of classification model base class for
    three test samples.
    """
        model = ClassificationModel()

        actualLabels = [
            numpy.array([0]),
            numpy.array([0, 2]),
            numpy.array([0, 1, 2])
        ]
        predictedLabels = [numpy.array([0]), [None], numpy.array([1, 2, 0])]
        classifications = [predictedLabels, actualLabels]

        self.assertAlmostEqual(model.calculateAccuracy(classifications),
                               float(2) / 3)