コード例 #1
0
def main(args):

    root = recur(os.path.dirname, os.path.realpath(__file__), n=2)

    if not os.path.isabs(args.labelFile):
        args.labelDir = os.path.join(root, args.labelFile)

    if not os.path.isabs(args.dataDir):
        args.dataDir = os.path.join(root, args.dataDir)

    corpus = Corpus(args.dataDir)

    empty_labels = {
        p: []
        for p in list(corpus.dataFiles.keys()) if "Known" not in p
    }

    with open(args.labelFile, "w") as outFile:
        outFile.write(
            json.dumps(empty_labels,
                       sort_keys=True,
                       indent=4,
                       separators=(',', ': ')))

    print("Empty label file written to", args.labelFile)
コード例 #2
0
def main(args):
    if not args.absolutePaths:
        root = recur(os.path.dirname, os.path.realpath(__file__), 2)
        dataDir = os.path.join(root, args.dataDir)
        labelDir = os.path.join(root, args.labelDir)
    else:
        dataDir = args.dataDir
        labelDir = args.labelDir

    # The following params are used in NAB scoring, but defined here because they
    # impact the labeling process -- i.e. windows cannot exist in the probationary
    # period.
    windowSize = 0.10
    probationaryPercent = 0.15

    print("Getting corpus.")
    corpus = Corpus(dataDir)

    print("Creating LabelCombiner.")
    labelCombiner = LabelCombiner(labelDir, corpus, args.threshold, windowSize,
                                  probationaryPercent, args.verbosity)

    print("Combining labels.")
    labelCombiner.combine()

    print("Writing combined labels files.")
    labelCombiner.write(args.combinedLabelsPath, args.combinedWindowsPath)

    print("Attempting to load objects as a test.")
    corpusLabel = CorpusLabel(args.combinedWindowsPath, corpus)
    corpusLabel.validateLabels()

    print("Successfully combined labels!")
    print("Resulting windows stored in:", args.combinedWindowsPath)
コード例 #3
0
def main(args):

  if not args.detector:
    raise ValueError("Must specify detector name (--detector).")

  root = recur(os.path.dirname, os.path.realpath(__file__), 2)
  thresholdFile = os.path.join(root, args.thresholdFile)
  resultsDir = os.path.join(root, args.resultsDir)

  categorySubDirs = getCategoryNames(args.dataDir, root)

  createThresholds(args.detector, thresholdFile)
  
  createResultsDir(args.detector, resultsDir, categorySubDirs)
コード例 #4
0
ファイル: create_new_detector.py プロジェクト: nathanielc/NAB
def main(args):

    if not args.detector:
        raise ValueError("Must specify detector name (--detector).")

    root = recur(os.path.dirname, os.path.realpath(__file__), 2)
    thresholdFile = os.path.join(root, args.thresholdFile)
    resultsDir = os.path.join(root, args.resultsDir)

    categorySubDirs = getCategoryNames(args.dataDir, root)

    createThresholds(args.detector, thresholdFile)

    createResultsDir(args.detector, resultsDir, categorySubDirs)
コード例 #5
0
def main(args):

  root = recur(os.path.dirname, os.path.realpath(__file__), n=2)

  if not os.path.isabs(args.labelFile):
    args.labelDir = os.path.join(root, args.labelFile)

  if not os.path.isabs(args.dataDir):
    args.dataDir = os.path.join(root, args.dataDir)

  corpus = Corpus(args.dataDir)

  empty_labels = {p : [] for p in corpus.dataFiles.keys()}

  with open(args.labelFile, "w") as outFile:
    outFile.write(json.dumps(empty_labels,
             sort_keys=True, indent=4, separators=(',', ': ')))

  print "Empty label file written to",args.labelFile
コード例 #6
0
ファイル: combine_labels.py プロジェクト: Aleyasen/NAB
def main(args):
  if not args.absolutePaths:
    root = recur(os.path.dirname, os.path.realpath(__file__), 2)
    dataDir = os.path.join(root, args.dataDir)
    labelDir = os.path.join(root, args.labelDir)
  else:
    dataDir = args.dataDir
    labelDir = args.labelDir

  # The following params are used in NAB scoring, but defined here because they
  # impact the labeling process -- i.e. windows cannot exist in the probationary
  # period.
  windowSize = 0.10
  probationaryPercent = 0.15


  print "Getting corpus."
  corpus = Corpus(dataDir)

  print "Creating LabelCombiner."
  labelCombiner = LabelCombiner(labelDir, corpus,
                                args.threshold, windowSize,
                                probationaryPercent, args.verbosity)

  print "Combining labels."
  labelCombiner.combine()

  print "Writing combined labels files."
  labelCombiner.write(args.combinedLabelsPath, args.combinedWindowsPath)

  print "Attempting to load objects as a test."
  corpusLabel = CorpusLabel(args.combinedWindowsPath, corpus)
  corpusLabel.validateLabels()

  print "Successfully combined labels!"
  print "Resulting windows stored in:", args.combinedWindowsPath
コード例 #7
0
# along with this program.  If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# ----------------------------------------------------------------------

import os
import argparse
import pandas

from nab.corpus import Corpus
from nab.labeler import CorpusLabel
from nab.util import recur, checkInputs

depth = 2

root = recur(os.path.dirname, os.path.realpath(__file__), depth)


def main(args):

    if not args.absolutePaths:
        args.labelDir = os.path.join(root, args.labelDir)
        args.dataDir = os.path.join(root, args.dataDir)
        args.destDir = os.path.join(root, args.destDir)

    if not checkInputs(args):
        return

    corpus = Corpus(args.dataDir)

    corpusLabel = CorpusLabel(args.labelDir, corpus=corpus)
コード例 #8
0
ファイル: combine_labels.py プロジェクト: MauricioRoman/NAB
"""

import argparse
import os
import pprint
import time

from nab.corpus import Corpus
from nab.labeler import LabelCombiner, CorpusLabel
from nab.util import recur, checkInputs



depth = 2

root = recur(os.path.dirname, os.path.realpath(__file__), depth)

def main(args):
  if not args.absolutePaths:
    dataDir = os.path.join(root, args.dataDir)
    labelDir = os.path.join(root, args.labelDir)
  else:
    dataDir = args.dataDir
    labelDir = args.labelDir

  # The following params are used in NAB scoring, but defined here because they
  # impact the labeling process -- i.e. windows cannot exist in the probationary
  # period.
  windowSize = 0.10
  probationaryPercent = 0.15
コード例 #9
0
ファイル: corpus_test.py プロジェクト: plexzhang/NAB
    def setUpClass(cls):
        depth = 3

        cls.root = recur(os.path.dirname, os.path.realpath(__file__), depth)
        cls.corpusSource = os.path.join(cls.root, "tests", "test_data")
コード例 #10
0
ファイル: combine_labels.py プロジェクト: breznak/NAB
# ----------------------------------------------------------------------
"""
Combines a set of labels given within folder (in the yaml format)
"""

import os
from os.path import dirname, realpath
import argparse

from nab.labeler import LabelCombiner, CorpusLabel

from nab.util import recur, checkInputs

depth = 2

root = recur(dirname, realpath(__file__), depth)

def main(args):

  dataDir = os.path.join(root, args.dataDir)
  destDir = args.destDir
  labelDir = args.labelDir

  threshold = 1

  labelCombiner = LabelCombiner(labelDir, dataDir, threshold)

  print "Combining Labels"

  labelCombiner.combine()
コード例 #11
0
    def setUpClass(cls):
        depth = 3

        cls.root = recur(os.path.dirname, os.path.realpath(__file__), depth)
        cls.corpusSource = os.path.join(cls.root, "tests", "test_data")