當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。