コード例 #1
0
ファイル: ProcessResults.py プロジェクト: charanpald/wallhack
            newTrainOutputList = []
            newTestOutputList = []
            for item in outputList: 
                if item not in testExpertMatchesInds: 
                    newTrainOutputList.append(item)
                if item not in trainExpertMatchesInds: 
                    newTestOutputList.append(item)
              
            trainOutputLists.append(newTrainOutputList)
            testOutputLists.append(newTestOutputList)
        
        for i, n in enumerate(ns):     
            for j, trainOutputList in enumerate(trainOutputLists): 
                testOutputList = testOutputLists[j]                
                
                trainPrecisions[i, j] = Evaluator.precisionFromIndLists(trainExpertMatchesInds, trainOutputList[0:n]) 
                testPrecisions[i, j] = Evaluator.precisionFromIndLists(testExpertMatchesInds, testOutputList[0:n]) 
                averageTrainPrecisions[s, i, j] = Evaluator.averagePrecisionFromLists(trainExpertMatchesInds, trainOutputList[0:n], n)
                averageTestPrecisions[s, i, j] = Evaluator.averagePrecisionFromLists(testExpertMatchesInds, testOutputList[0:n], n) 

        #Now look at rank aggregations
        relevantItems = set([])
        for trainOutputList in trainOutputLists: 
            relevantItems = relevantItems.union(trainOutputList)
        relevantItems = list(relevantItems)
        
        listInds = RankAggregator.greedyMC2(trainOutputLists, relevantItems, trainExpertMatchesInds, 20) 
        
        newOutputList = []
        for listInd in listInds: 
            newOutputList.append(testOutputLists[listInd])
コード例 #2
0
ファイル: ReputationExp3.py プロジェクト: charanpald/wallhack
        methodNames = graphRanker.getNames()
        
        if runLSI: 
            outputFilename = dataset.getOutputFieldDir(field) + "outputListsLSI.npz"
        else: 
            outputFilename = dataset.getOutputFieldDir(field) + "outputListsLDA.npz"
            
        Util.savePickle([outputLists, trainExpertMatchesInds, testExpertMatchesInds], outputFilename, debug=True)
        
        numMethods = len(outputLists)
        precisions = numpy.zeros((len(ns), numMethods))
        averagePrecisions = numpy.zeros(numMethods)
        
        for i, n in enumerate(ns):     
            for j in range(len(outputLists)): 
                precisions[i, j] = Evaluator.precisionFromIndLists(testExpertMatchesInds, outputLists[j][0:n]) 
            
        for j in range(len(outputLists)):                 
            averagePrecisions[j] = Evaluator.averagePrecisionFromLists(testExpertMatchesInds, outputLists[j][0:averagePrecisionN], averagePrecisionN) 
        
        precisions2 = numpy.c_[numpy.array(ns), precisions]
        
        logging.debug(Latex.listToRow(methodNames))
        logging.debug("Computing Precision")
        logging.debug(Latex.array2DToRows(precisions2))
        logging.debug("Computing Average Precision")
        logging.debug(Latex.array1DToRow(averagePrecisions))
#fermer le fichier 
fich.close()

logging.debug("All done!")