当前位置: 首页>>代码示例>>Python>>正文


Python Features.initializeContextVars方法代码示例

本文整理汇总了Python中Features.initializeContextVars方法的典型用法代码示例。如果您正苦于以下问题:Python Features.initializeContextVars方法的具体用法?Python Features.initializeContextVars怎么用?Python Features.initializeContextVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Features的用法示例。


在下文中一共展示了Features.initializeContextVars方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getSingleFeatureLineFromFile

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def getSingleFeatureLineFromFile(file, decisions, shot, leave_out_class=None):
    """
    This is a less troublesome but slow method to get a featureLine.
    """
    beatList, context = getContextAndBeatListFromFile(file)
    blockList = coalesceBeats(beatList)
    Features.initializeContextVars(context)
    lastShotId, context, blockList = applyDecisionsToBeatscript(context, blockList,
        decisions)
    featureLine = getFeatureLine(context, blockList[len(decisions)], shot, lastShotId,
        leave_out_class)
    return featureLine
开发者ID:flair2005,项目名称:Automoculus,代码行数:14,代码来源:ConvertData.py

示例2: createFeatureLines

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def createFeatureLines(context, beatList, shot, leave_out_class=None):
    """
    Returns the list of featureLines converted from the Beats in beatList
    """
    featureLines = []
    blockList = coalesceBeats(beatList)
    Features.initializeContextVars(context)
    lastShotId = -1
    for block in blockList:
        featureLines.append(
            getFeatureLine(context, block, shot, lastShotId, leave_out_class))
        context["BygoneBlocks"].append(block)
        lastShotId = block[-1].shotId
    return featureLines
开发者ID:flair2005,项目名称:Automoculus,代码行数:16,代码来源:ConvertData.py

示例3: getFeatureNames

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def getFeatureNames(leave_out_class=None):
    """
    Returns an array of feature names corresponding to the featureLine.
    """
    names = []
    featureClassList = Features.getAllFeatureClasses()
    context = createContext()
    dummy_beat = Beat("0_1\tfull_shot\tfalse\tintroduce\tperson§Nobody", context)
    context = Features.createBeatList(context, [dummy_beat])
    Features.initializeContextVars(context)
    for featureClass in [x for x in featureClassList if x != leave_out_class]:
        feature = featureClass(context, [dummy_beat])
        names += feature.getNames()
    return names
开发者ID:flair2005,项目名称:Automoculus,代码行数:16,代码来源:ConvertData.py

示例4: getSingleFeatureLine

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def getSingleFeatureLine(context, blockList, decisions, shot, leave_out_class=None):
    """
    Returns a featureLine based on the context and the decisions.
    """
    Features.initializeContextVars(context)
    lastShotId, context, blockList = applyDecisionsToBeatscript(context, blockList,
        decisions)
    # This is for preventing the classifier to cheat by using the correct class.
    # Activate if you're suspicious.
    #for beat in blockList[len(decisions)]:
    #    beat.shot = 0
    featureLine = getFeatureLine(context, blockList[len(decisions)], shot, lastShotId,
        leave_out_class)
    return featureLine
开发者ID:flair2005,项目名称:Automoculus,代码行数:16,代码来源:ConvertData.py

示例5: main

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def main():
    beatscriptFile = open(sys.argv[1], "r")
    lines = beatscriptFile.readlines()
    context = readContext(lines)
    beatList = readBeatscript(lines, context)
    blockList = coalesceBeats(beatList)
    Features.initializeContextVars(context)
    dataLines = []
    for block in blockList:
        dataLines.append(createDataLine(context, block))
        context["BygoneBlocks"].append(block)

    outputFile = open(sys.argv[2], "w")
    for dataLine in dataLines:
        outputFile.write(DELIMITER.join([str(x) for x in dataLine]) + "\n")
        #outputFile.write(DELIMITER.join(dataLine) + "\n")
    outputFile.close()
开发者ID:flair2005,项目名称:Automoculus,代码行数:19,代码来源:ConvertData.py

示例6: onlineFeatureLineCreator

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def onlineFeatureLineCreator(filename, use_classified_shot = False, use_history = True):
    # load context and complete beatlist from file
    context, beatList = getContextAndBeatListFromFile(filename)
    Features.initializeContextVars(context)
    blockList = coalesceBeats(beatList)
    context["BygoneBlocks"] = []
    for block in blockList:
        shot_true = block[-1].shot
        # get current feature line and true shot class
        featureLine = getFeatureLine(context, block, True, -1)
        features = np.array(featureLine[:-1], dtype=np.float64)
        shot_classified = yield features, shot_true
        # update block and lastShotId
        if use_classified_shot:
            for beat in block:
                beat.shot = shot_classified
        if use_history:
            context["BygoneBlocks"].append(block)
开发者ID:flair2005,项目名称:Automoculus,代码行数:20,代码来源:zmltests.py

示例7: main

# 需要导入模块: import Features [as 别名]
# 或者: from Features import initializeContextVars [as 别名]
def main():
    if len(sys.argv) < 2:
        print("Usage: python ClassificationProcess.py <Beatscript-Filename>")
        return 1
    # Initialization and Training
    classifiers, scaler = trainWithAllExamples(True)
    cutClassifiers, cutScaler = trainWithAllExamples(False)
    try:
        beatscript_file = open(sys.argv[1], "r")
    except IOError:
        print("Error: The Beatscipt could not be opened.")
        print("Usage: python ClassificationProcess.py <Beatscript-Filename>")
        return 1
    lines = beatscript_file.readlines()
    context = readContext(lines)#
    beatscript = readBeatscript(lines, context)
    Features.initializeContextVars(context)
    beatList = getBeatsBetweenFrames(beatscript, -1, 0)
    current_frame = 0
    lastBlock = beatList
    context["BygoneBlocks"] = []
    sys.stdout.write("Training finished." + "\n")
    sys.stdout.flush()
    # Get Distribution
    dist = classifyForShot(lastBlock, context, classifiers, scaler)
    cutBeforeThisClassification = classifyForCut(lastBlock, context, cutClassifiers,
        cutScaler)
    while True:
        choice = raw_input("")
        if choice == "e":
            printListOfEntities(context)
        elif choice == "t": # get the names of the target and the linetarget
            determine_targets(context, lastBlock)
        elif choice == "p": # print out the classification propabilities
            pickle.dump(dist, sys.stdout)

        elif choice == "c": # Print out, if we should cut at this point
            blockList = []
            decisions = []
            for block in context["BygoneBlocks"]:
                blockList.append(block)
                decisions.append(block[0].shot)
            blockList.append(lastBlock)
            decisions.append(dist.index(max(dist)))
            if cutBeforeThisClassification[0] < cutBeforeThisClassification[1]:
                sys.stdout.write("yes\n")
            else:
                sys.stdout.write("no\n")

        elif choice == "f": # check framenumber for a new block
            new_frame = int(raw_input(""))
            beatList = getBeatsBetweenFrames(beatscript, current_frame, new_frame)
            current_frame = new_frame
            if beatList :
                context["BygoneBlocks"].append(lastBlock)
                lastBlock = beatList
                dist = classifyForShot(lastBlock, context, classifiers, scaler)
                cutBeforeThisClassification = classifyForCut(lastBlock, context, cutClassifiers, cutScaler)
                sys.stdout.write("yes\n")
            else:
                sys.stdout.write("no\n")

        elif choice == "d": # recieve the decision for the lastBlock
            decision = int(raw_input(""))
            for beat in lastBlock:
                beat.shot = decision
            sys.stdout.write("decision recieved\n")

        elif choice == "q": # quit...
            sys.stdout.write("exiting...\n")
            sys.stdout.flush()
            break
        else:
            sys.stdout.write("You didn't enter something useful.\n")
        sys.stdout.flush()
开发者ID:flair2005,项目名称:Automoculus,代码行数:77,代码来源:ClassificationProcess.py


注:本文中的Features.initializeContextVars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。