def testClassifyKeywordsAsExpected(self):
    """
    Tests ClassificationModelKeywords.

    Training on the first five samples of the dataset, and testing on the rest,
    the model's classifications should match those in the expected classes
    data file.
    """
    modelName = "Keywords"
    runner = Runner(dataPath=os.path.join(DATA_DIR, "responses.csv"),
                    resultsDir="",
                    experimentName="keywords_test",
                    experimentType="incremental",
                    loadPath=None,
                    modelName=modelName,
                    numClasses=3,
                    plots=0,
                    orderedSplit=True,
                    trainSizes=[5],
                    verbosity=0)
    runner.initModel(modelName)
    self.runExperiment(runner)

    expectedClasses, resultClasses = self.getExpectedClassifications(
      runner, os.path.join(DATA_DIR, "responses_expected_classes_keywords.csv"))

    for i, (e, r) in enumerate(zip(expectedClasses, resultClasses)):
      if i in (7, 9, 12):
        # Ties amongst winning labels are handled randomly, which affects the
        # third classification in these test samples.
        e = e[:2]
        r = r[:2]
      self.assertEqual(sorted(e), sorted(r),
      "Keywords model predicted classes other than what we expect.")
  def testClassifyEndpointAsExpected(self):
    """
    Tests ClassificationModelEndpoint.

    Training on the first five samples of the dataset, and testing on the rest,
    the model's classifications should match those in the expected classes
    data file.
    """
    modelName = "CioEndpoint"
    runner = Runner(dataPath=os.path.join(DATA_DIR, "responses.csv"),
                    resultsDir="",
                    experimentName="endpoint_test",
                    experimentType="incremental",
                    loadPath=None,
                    modelName=modelName,
                    numClasses=3,
                    plots=0,
                    orderedSplit=True,
                    trainSizes=[5],
                    verbosity=0)
    runner.initModel(modelName)
    self.runExperiment(runner)

    expectedClasses, resultClasses = self.getExpectedClassifications(runner,
      os.path.join(DATA_DIR, "responses_expected_classes_endpoint.csv"))

    [self.assertEqual(sorted(e), sorted(r),
      "Endpoint model predicted classes other than what we expect.")
      for e, r in zip(expectedClasses, resultClasses)]
Exemple #3
0
    def testClassifyEndpointAsExpected(self):
        """
    Tests ClassificationModelEndpoint.

    Training on the first five samples of the dataset, and testing on the rest,
    the model's classifications should match those in the expected classes
    data file.
    """
        modelName = "CioEndpoint"
        runner = Runner(dataPath=os.path.join(DATA_DIR, "responses.csv"),
                        resultsDir="",
                        experimentName="endpoint_test",
                        experimentType="incremental",
                        loadPath=None,
                        modelName=modelName,
                        numClasses=3,
                        plots=0,
                        orderedSplit=True,
                        trainSizes=[5],
                        verbosity=0)
        runner.initModel(modelName)
        self.runExperiment(runner)

        expectedClasses, resultClasses = self.getExpectedClassifications(
            runner,
            os.path.join(DATA_DIR, "responses_expected_classes_endpoint.csv"))

        [
            self.assertEqual(
                sorted(e), sorted(r),
                "Endpoint model predicted classes other than what we expect.")
            for e, r in zip(expectedClasses, resultClasses)
        ]
Exemple #4
0
    def testClassifyKeywordsAsExpected(self):
        """
    Tests ClassificationModelKeywords.

    Training on the first five samples of the dataset, and testing on the rest,
    the model's classifications should match those in the expected classes
    data file.
    """
        modelName = "Keywords"
        runner = Runner(dataPath=os.path.join(DATA_DIR, "responses.csv"),
                        resultsDir="",
                        experimentName="keywords_test",
                        experimentType="incremental",
                        loadPath=None,
                        modelName=modelName,
                        numClasses=3,
                        plots=0,
                        orderedSplit=True,
                        trainSizes=[5],
                        verbosity=0)
        runner.initModel(modelName)
        self.runExperiment(runner)

        expectedClasses, resultClasses = self.getExpectedClassifications(
            runner,
            os.path.join(DATA_DIR, "responses_expected_classes_keywords.csv"))

        for i, (e, r) in enumerate(zip(expectedClasses, resultClasses)):
            if i in (7, 9, 12):
                # Ties amongst winning labels are handled randomly, which affects the
                # third classification in these test samples.
                e = e[:2]
                r = r[:2]
            self.assertEqual(
                sorted(e), sorted(r),
                "Keywords model predicted classes other than what we expect.")