Skip to content
Browse files

add more outputs to tryprune.py

  • Loading branch information...
1 parent 499b18a commit 9907d860802ea03319ca283f0e7f4737765c5513 @epico epico committed Jul 28, 2011
Showing with 15 additions and 11 deletions.
  1. +2 −4 evaluate.py
  2. +13 −7 tryprune.py
View
6 evaluate.py
@@ -165,8 +165,7 @@ def evaluateModel(reportfile):
buildData()
print('estimating')
- reportfile = os.path.join \
- (trydir, 'estimate' + config.getReportPostfix())
+ reportfile = os.path.join(trydir, 'estimate' + config.getReportPostfix())
avg_lambda = estimateModel(reportfile)
cwdstatus['EvaluateAverageLambda'] = avg_lambda
@@ -176,8 +175,7 @@ def evaluateModel(reportfile):
modifyCodeforLambda(avg_lambda)
print('evaluating')
- reportfile = os.path.join \
- (trydir, 'evaluate' + config.getReportPostfix())
+ reportfile = os.path.join(trydir, 'evaluate' + config.getReportPostfix())
rate = evaluateModel(reportfile)
print(tryname + "'s correction rate:", rate)
View
20 tryprune.py
@@ -68,8 +68,6 @@ def convertModel(kmm_model, inter_model):
def mergeOneModel(mergedmodel, onemodel, score):
- #validate first
- validateModel(onemodel)
onemodelstatuspath = onemodel + config.getStatusPostfix()
onemodelstatus = utils.load_status(onemodelstatuspath)
@@ -107,14 +105,16 @@ def mergeSomeModels(mergedmodel, sortedindexname, mergenum):
raise AssertionError('scores must be descending.\n')
onemodel = os.path.join(config.getModelDir(), subdir, modelname)
+
+ #validate first
+ print('validating')
+ validateModel(onemodel)
+
mergeOneModel(mergedmodel, onemodel, score)
last_score = score
indexfile.close()
#end processing
- #validate merged model
- validateModel(mergedmodel)
-
def pruneModel(prunedmodel, k, CDF):
#begin processing
@@ -129,8 +129,6 @@ def pruneModel(prunedmodel, k, CDF):
sys.exit('Corrupted model found when pruning:' + modelfile)
#end processing
- #validate pruned model
- validateModel(prunedmodel)
if __name__ == '__main__':
parser = ArgumentParser(description='Try prune models.')
@@ -178,6 +176,10 @@ def pruneModel(prunedmodel, k, CDF):
config.getSortedEstimateIndex())
mergeSomeModels(mergedmodel, sortedindexname, args.merge)
+ #validate merged model
+ print('validating')
+ validateModel(mergedmodel)
+
#export textual format
print('exporting')
exportfile = os.path.join(trydir, 'kmm_merged.text')
@@ -190,6 +192,10 @@ def pruneModel(prunedmodel, k, CDF):
shutil.copyfile(mergedmodel, prunedmodel)
pruneModel(prunedmodel, args.k, args.CDF)
+ #validate pruned model
+ print('validating')
+ validateModel(prunedmodel)
+
#export textual format
print('exporting')
exportfile = os.path.join(trydir, 'kmm_pruned.text')

0 comments on commit 9907d86

Please sign in to comment.
Something went wrong with that request. Please try again.