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 "
Beispiel #2
0
def main(argv):
    try:
        p2 = phase2()
        wd = argv[
            0]  # Joint Cost Model's Working Directory (Resp and Priv Category )
        workDirResponsive = argv[1]  # Responsive Category Working Directory '
        workDirPrivilege = argv[2]  # Privilege Category Working Directory '
        numTestInstances = argv[3]
        rJFile = 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()
        lamR = cMatrix.getLam_r()
        p2.computeExpectation(
            wd, numTestInstances, cmv, lamR,
            workDirResponsive + '/pickleFiles/ds-op-label.tuple.dictionary.' +
            str(numTestInstances) + '.p',
            workDirPrivilege + '/pickleFiles/ds-op-label.tuple.dictionary.' +
            str(numTestInstances) + '.p')
        tau_rValue = p2.runphase2(
            workDirResponsive + '/pickleFiles/ds-op-label.tuple.dictionary.' +
            str(numTestInstances) + '.p',
            workDirPrivilege + '/pickleFiles/ds-op-label.tuple.dictionary.' +
            str(numTestInstances) + '.p', rJFile, wd, numTestInstances, 0)
    except:
        raise
Beispiel #3
0
def p2caller(pl, pw, lp, lw, wp, wl, alpha, lambda_R):
    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()
        lamR = lambda_R
        p2 = phase2()
        twd = '/app/data'
        p2.computeExpectation(
            twd, 20000, cmvalue, lamR,
            twd + '/GPOL-ds-op-label.tuple.dictionary.20000.p',
            twd + '/ECAT-ds-op-label.tuple.dictionary.20000.p')
        Tau_rValue = p2.runphase2(
            twd + '/GPOL-ds-op-label.tuple.dictionary.20000.p',
            twd + '/ECAT-ds-op-label.tuple.dictionary.20000.p',
            twd + '/rcv1_GPOL.txt', twd, 20000, 0)
        return Tau_rValue
    except:
        raise