def run(self,prbCrFile,prbCpFile,wd,trf,tpf,rJf,pJf,totalTestInstances,cMatrix): prCr=cPickle.load(open(prbCrFile,'rb')) prCp=cPickle.load(open(prbCpFile,'rb')) prCrRanked=self.RankByProbability(prCr,"DEC") prCpRanked=self.RankByProbability(prCp,"DEC") Tau_r=self.get_tauR(trf) docids2Annotatep2=[] for docID,probVal in prCrRanked.items(): if not Tau_r==0: docids2Annotatep2.append(docID) Tau_r=Tau_r-1 cPickle.dump(docids2Annotatep2,open(wd+'/docs4map2RRBaseline.list.'+str(totalTestInstances)+'.p', 'wb')) p2=phase2() p2.cmv=cMatrix p2.runphase2(prbCrFile,prbCpFile,rJf,wd,totalTestInstances,self.get_tauR(trf),BaselineType='RR') Tau_p=self.get_tauP(tpf) docids2Annotatep3=[] for doID,pVal in prCpRanked.items(): if not Tau_p==0: docids2Annotatep3.append(doID) Tau_p=Tau_p-1 cPickle.dump(docids2Annotatep3,open(wd+'/docs4map3RRBaseline.list.'+str(totalTestInstances)+'.p', 'wb')) p3=phase3() p3.cmv=cMatrix p3.runphase3(prbCpFile,pJf,wd,totalTestInstances,self.get_tauP(tpf),BaselineType='RR') c_a=self.ComputeManualAnnotationCost(self.get_tauR(trf),self.get_tauP(tpf)) print "Annotation Cost= ",c_a c_m=self.ComputeMisclassificationCost(wd,rJf,pJf,totalTestInstances,cMatrix) print "Misclassification Cost= ",c_m print "RESULTVALUE ",c_m print "Ending Relevance Ranking Baseline Model "
def p3caller(pl, pw, lp, lw, wp, wl, alpha, lambda_P): try: costMatrix = cm() costMatrix.setCostMatrix(float(pl), float(pw), float(lp), float(lw), float(wp), float(wl)) costMatrix.setAlpha(float(alpha.strip())) cmvalue = costMatrix.getCostMatrix() lamP = float(lambda_P) twd = '/app/data' p3 = phase3() p3.computeExpectation( twd, 20000, cmvalue, lamP, twd + '/ECAT-ds-op-label.tuple.dictionary.20000.p') Tau_pValue = p3.runphase3( twd + '/ECAT-ds-op-label.tuple.dictionary.20000.p', twd + '/rcv1_ECAT.txt', twd, 20000, 0) return Tau_pValue except: raise
def main(argv): try: p3 = phase3() wd = argv[ 0] # Joint Cost Model's Working Directory (Specific Resp and Priv Cat ) workDirResponsive = argv[1] # Responsive WD ' workDirPrivilege = argv[2] # Privilege WD ' numTestInstances = argv[3] pJFile = argv[4] cMatrix = cm() cMatrix.setCostMatrix(float(argv[5]), float(argv[6]), float(argv[7]), float(argv[8]), float(argv[9]), float(argv[10])) cMatrix.setAlpha(float(argv[11])) cmv = cMatrix.getCostMatrix() lamP = cMatrix.getLam_p() p3.computeExpectation( wd, numTestInstances, cmv, lamP, workDirPrivilege + '/pickleFiles/ds-op-label.tuple.dictionary.' + str(numTestInstances) + '.p') p3.runphase3( workDirPrivilege + '/pickleFiles/ds-op-label.tuple.dictionary.' + str(numTestInstances) + '.p', pJFile, wd, numTestInstances, 0) except: raise