Пример #1
0
    def testBaselineScoreLoading(self):
        """Tests that we fail apropriately if baseline scores are absent."""

        testRunner = Runner(dataDir=None, resultsDir="", labelPath=None, profilesPath=None, thresholdPath=None)

        # Should fail due to resultsDir/baseline not being a directory.
        with self.assertRaises(IOError):
            testRunner.normalize()

        tmpResultsDir = self._createTemporaryResultsDir()
        os.makedirs(os.path.join(tmpResultsDir, "baseline"))

        testRunner2 = createRunner(tmpResultsDir, "standard")

        # Should fail due to resultsDir/baseline being empty.
        with self.assertRaises(IOError):
            testRunner2.normalize()
Пример #2
0
def main(args):

    root = os.path.dirname(os.path.realpath(__file__))

    numCPUs = int(args.numCPUs) if args.numCPUs is not None else None

    dataDir = os.path.join(root, args.dataDir)
    windowsFile = os.path.join(root, args.windowsFile)
    resultsDir = os.path.join(root, args.resultsDir)
    profilesFile = os.path.join(root, args.profilesFile)
    thresholdsFile = os.path.join(root, args.thresholdsFile)

    runner = Runner(dataDir=dataDir,
                    labelPath=windowsFile,
                    resultsDir=resultsDir,
                    profilesPath=profilesFile,
                    thresholdPath=thresholdsFile,
                    numCPUs=numCPUs)

    runner.initialize()

    if args.detect:
        detectorConstructors = getDetectorClassConstructors(args.detectors)
        print("Starting Evaluation!!\n")
        start_time = datetime.datetime.now()
        runner.detect(detectorConstructors)
        delta = datetime.datetime.now() - start_time
        print("Total time for classification in milliseconds " +
              str(int(delta.total_seconds() * 1000)) + '\n')
        #print("Total time for classification: " + str(delta) + '\n')

    if args.optimize:
        runner.optimize(args.detectors)

    if args.score:
        with open(args.thresholdsFile) as thresholdConfigFile:
            detectorThresholds = json.load(thresholdConfigFile)
        runner.score(args.detectors, detectorThresholds)

    if args.normalize:
        try:
            runner.normalize()
        except AttributeError("Error: you must run the scoring step with the "
                              "normalization step."):
            return
Пример #3
0
  def testNullScoreLoading(self):
    """Tests that we fail apropriately if null detector scores are absent."""

    testRunner = Runner(dataDir=None,
                        resultsDir='',
                        labelPath=None,
                        profilesPath=None,
                        thresholdPath=None)

    # Should fail due to resultsDir/null not being a directory.
    with self.assertRaises(IOError):
      testRunner.normalize()

    tmpResultsDir = self._createTemporaryResultsDir()
    os.makedirs(os.path.join(tmpResultsDir,'null'))

    testRunner2 = createRunner(tmpResultsDir, 'standard')

    # Should fail due to resultsDir/null being empty.
    with self.assertRaises(IOError):
      testRunner2.normalize()
Пример #4
0
    def testBaselineScoreLoading(self):
        """Tests that we fail apropriately if baseline scores are absent."""

        testRunner = Runner(dataDir=None,
                            resultsDir='',
                            labelPath=None,
                            profilesPath=None,
                            thresholdPath=None)

        # Should fail due to resultsDir/baseline not being a directory.
        with self.assertRaises(IOError):
            testRunner.normalize()

        tmpResultsDir = self._createTemporaryResultsDir()
        os.makedirs(os.path.join(tmpResultsDir, 'baseline'))

        testRunner2 = createRunner(tmpResultsDir, 'standard')

        # Should fail due to resultsDir/baseline being empty.
        with self.assertRaises(IOError):
            testRunner2.normalize()
Пример #5
0
def main(args):
  
  root = os.path.dirname(os.path.realpath(__file__))

  numCPUs = int(args.numCPUs) if args.numCPUs is not None else None

  dataDir = os.path.join(root, args.dataDir)
  labelFile = os.path.join(root, args.labelFile)
  resultsDir = os.path.join(root, args.resultsDir)
  profilesFile = os.path.join(root, args.profilesFile)
  thresholdsFile = os.path.join(root, args.thresholdsFile)
  
  runner = Runner(dataDir=dataDir,
                  labelPath=labelFile,
                  resultsDir=resultsDir,
                  profilesPath=profilesFile,
                  thresholdPath=thresholdsFile,
                  numCPUs=numCPUs)

  runner.initialize()

  if args.detect:
    detectorConstructors = getDetectorClassConstructors(
      args.detectors[0].split(','))
    runner.detect(detectorConstructors)

  if args.optimize:
    runner.optimize(args.detectors)

  if args.score:
    with open(args.thresholdsFile) as thresholdConfigFile:
      detectorThresholds = json.load(thresholdConfigFile)
    runner.score(args.detectors, detectorThresholds)

  if args.normalize:
    try:
      runner.normalize()
    except AttributeError("Error: you must run the scoring step with the "
                          "normalization step."):
      return
Пример #6
0
def main(args):
    numCPUs = int(args.numCPUs) if args.numCPUs is not None else None

    dataDir = args.dataDir
    windowsFile = args.windowsFile
    resultsDir = args.resultsDir
    profilesFile = args.profilesFile
    thresholdsFile = args.thresholdsFile

    runner = Runner(dataDir=dataDir,
                    labelPath=windowsFile,
                    resultsDir=resultsDir,
                    profilesPath=profilesFile,
                    thresholdPath=thresholdsFile,
                    numCPUs=numCPUs)

    runner.initialize()

    if args.detect:
        detectorConstructors = getDetectorClassConstructors(args.detectors)
        runner.detect(detectorConstructors)

    if args.optimize:
        runner.optimize(args.detectors)

    if args.score:
        with open(args.thresholdsFile) as thresholdConfigFile:
            detectorThresholds = json.load(thresholdConfigFile)
        runner.score(args.detectors, detectorThresholds)

    if args.normalize:
        try:
            runner.normalize()
        except AttributeError("Error: you must run the scoring step with the "
                              "normalization step."):
            return