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)
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)
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)
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
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
# 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)
""" 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
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")
# ---------------------------------------------------------------------- """ 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()