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


Python IdSet.load方法代码示例

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


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

示例1: getIdSets

# 需要导入模块: from Core.IdSet import IdSet [as 别名]
# 或者: from Core.IdSet.IdSet import load [as 别名]
 def getIdSets(self, classIds=None, featureIds=None, allowNewIds=True):
     # Class ids
     #print classIds
     #print featureIds
     if classIds != None and os.path.exists(classIds):
         print >> sys.stderr, "Using predefined class names from", classIds
         classSet = IdSet(allowNewIds=allowNewIds)
         classSet.load(classIds)
     else:
         print >> sys.stderr, "No predefined class names"
         classSet = None
     # Feature ids
     if featureIds != None and os.path.exists(featureIds):
         print >> sys.stderr, "Using predefined feature names from", featureIds
         featureSet = IdSet(allowNewIds=allowNewIds)
         featureSet.load(featureIds)
     else:
         print >> sys.stderr, "No predefined feature names"
         featureSet = None
     return classSet, featureSet
开发者ID:DUT-LiuYang,项目名称:TEES,代码行数:22,代码来源:ExampleBuilder.py

示例2: OptionParser

# 需要导入模块: from Core.IdSet import IdSet [as 别名]
# 或者: from Core.IdSet.IdSet import load [as 别名]
        psyco.full()
        print >> sys.stderr, "Found Psyco, using"
    except ImportError:
        print >> sys.stderr, "Psyco not installed"
    
    defaultAnalysisFilename = "/usr/share/biotext/ComplexPPI/BioInferForComplexPPIVisible.xml"
    optparser = OptionParser(usage="%prog [options]\nCreate an html visualization for a corpus.")
    optparser.add_option("-i", "--invariant", default=None, dest="invariant", help="Corpus in analysis format", metavar="FILE")
    optparser.add_option("-v", "--variant", default=None, dest="variant", help="Corpus in analysis format", metavar="FILE")
    (options, args) = optparser.parse_args()
    
    #invariantExamples = ExampleUtils.readExamples(os.path.join(options.invariant, "examples.txt"))
    variantExamples = ExampleUtils.readExamples(os.path.join(options.variant, "test-triggers.examples"))
    
    invariantFeatureSet = IdSet()
    invariantFeatureSet.load(os.path.join(options.invariant, "feature_names.txt"))
    invariantClassSet = IdSet()
    invariantClassSet.load(os.path.join(options.invariant, "class_names.txt"))

    variantFeatureSet = IdSet()
    variantFeatureSet.load(os.path.join(options.variant, "test-triggers.examples.feature_names"))
    variantClassSet = IdSet()
    variantClassSet.load(os.path.join(options.variant, "test-triggers.examples.class_names"))
    
    counter = ProgressCounter(len(variantExamples))
    for example in variantExamples:
        counter.update()
        example[1] = invariantClassSet.getId(variantClassSet.getName(example[1]))
        newFeatures = {}
        for k,v in example[2].iteritems():
            newFeatures[ invariantFeatureSet.getId(variantFeatureSet.getName(k)) ] = v
开发者ID:jbjorne,项目名称:Tdevel,代码行数:33,代码来源:RealignExamples.py

示例3: splitParameters

# 需要导入模块: from Core.IdSet import IdSet [as 别名]
# 或者: from Core.IdSet.IdSet import load [as 别名]
     
     # Optimize
     optimizationSets = Example.divideExamples(exampleSets[0])
     evaluationArgs = {"classSet":exampleBuilder.classSet}
     if options.parameters != None:
         paramDict = splitParameters(options.parameters)
         bestResults = classifier.optimize([optimizationSets[0]], [optimizationSets[1]], paramDict, Evaluation, evaluationArgs)
     else:
         bestResults = classifier.optimize([optimizationSets[0]], [optimizationSets[1]], evaluationClass=Evaluation, evaluationArgs=evaluationArgs)
 else:
     print >> sys.stderr, "Using predefined model"
     bestResults = [None,None,{}]
     for k,v in classifierParamDict.iteritems():
         bestResults[2][k] = v
     featureSet = IdSet()
     featureSet.load(os.path.join(classifierParamDict["predefined"][0], "feature_names.txt"))
     classSet = None
     if os.path.exists(os.path.join(classifierParamDict["predefined"][0], "class_names.txt")):
         classSet = IdSet()
         classSet.load(os.path.join(classifierParamDict["predefined"][0], "class_names.txt"))
     exampleBuilder = ExampleBuilder(featureSet=featureSet, classSet=classSet, **splitParameters(options.exampleBuilderParameters))
 # Save training sets
 if options.output != None:
     print >> sys.stderr, "Saving example sets to", options.output
     Example.writeExamples(exampleSets[0], options.output + "/examplesTrain.txt")
     if not classifierParamDict.has_key("predefined"):
         Example.writeExamples(optimizationSets[0], options.output + "/examplesOptimizationTest.txt")
         Example.writeExamples(optimizationSets[1], options.output + "/examplesOptimizationTrain.txt")
     TableUtils.writeCSV(bestResults[2], options.output +"/best_parameters.csv")
 
 # Optimize and train
开发者ID:jbjorne,项目名称:Tdevel,代码行数:33,代码来源:SplitAnalysis.py


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