def monitoring(matrix, rate, roundId, para): startTime = time.clock() logger.info('rate=%.2f, %2d-round starts.'%(rate, roundId + 1)) # sampling logger.info('CS-PCA sampling...') startTime = time.clock() # to record the running time for one round (trainMatrix, observedMatrix, testMatrix) = CS_PCA.sampling(matrix, rate, roundId, para) # CS-PCA algorithm logger.info('CS-PCA estimation...') recoveredMatrix = CS_PCA.recover(trainMatrix, observedMatrix, para) runningTime = float(time.clock() - startTime) # evaluate the estimation error evalResult = evallib.evaluate(testMatrix, recoveredMatrix, para) result = (evalResult, runningTime) # dump the result at each rate outFile = '%s%s%s_result_%.2f%s.tmp'%(para['outPath'], para['dataName'], ('_%s'%para['dataType'] if ('dataType' in para.keys()) else ''), rate, '_round%02d'%(roundId + 1) if (para['rounds'] > 1) else '') evallib.dumpresult(outFile, result) logger.info('rate=%.2f, %2d-round done.'%(rate, roundId + 1)) logger.info('----------------------------------------------')
def executeOneSetting(matrix, density, roundId, para): logger.info('density=%.2f, %2d-round starts.' % (density, roundId + 1)) # remove data matrix (trainMatrix, testMatrix) = evallib.removeEntries(matrix, density, roundId) # QoS prediction startTime = time.clock() # to record the running time for one round predictedMatrix1 = UIPCC.UPCC(trainMatrix, para) predictedMatrix2 = UIPCC.IPCC(trainMatrix, para) predictedMatrix = UIPCC.UIPCC(trainMatrix, predictedMatrix1, predictedMatrix2, para) runningTime = float(time.clock() - startTime) # evaluate the estimation error evalResult = evallib.evaluate(testMatrix, predictedMatrix, para) result = (evalResult, runningTime) # dump the result at each density outFile = '%s%s_%s_result_%.2f_round%02d.tmp' % ( para['outPath'], para['dataName'], para['dataType'], density, roundId + 1) evallib.dumpresult(outFile, result) logger.info('density=%.2f, %2d-round done.' % (density, roundId + 1)) logger.info('----------------------------------------------')
def monitoring(matrix, rate, para): startTime = time.clock() logger.info("rate=%.2f starts." % rate) # JGD algorithm startTime = time.clock() # to record the running time for one round trainingPeriod = para["trainingPeriod"] trainMatrix = matrix[:, 0:trainingPeriod] testMatrix = matrix[:, trainingPeriod:] logger.info("monitor selection...") (selectedMonitors, toEstimateNodes) = JGD.selectMonitor(trainMatrix, rate, para) observedMatrix = testMatrix[selectedMonitors, :] logger.info("JGD estimation...") recoveredMatrix = JGD.recover(trainMatrix, observedMatrix, selectedMonitors, toEstimateNodes) runningTime = float(time.clock() - startTime) # evaluate the estimation error evalResult = evallib.evaluate(testMatrix, recoveredMatrix, para) result = (evalResult, runningTime) # dump the result at each rate outFile = "%s%s%s_result_%.2f.tmp" % ( para["outPath"], para["dataName"], "_%s" % para["dataType"] if ("dataType" in para.keys()) else "", rate, ) evallib.dumpresult(outFile, result) logger.info("rate=%.2f done." % rate) logger.info("----------------------------------------------")
def monitoring(matrix, rate, roundId, para): startTime = time.clock() logger.info('rate=%.2f, %2d-round starts.'%(rate, roundId + 1)) # sampling logger.info('CS sampling...') startTime = time.clock() # to record the running time for one round # sorting in ascending and permutation idx = np.argsort(-matrix[:, 0]) matrix = matrix[idx, :] (trainMatrix, observedMatrix, testMatrix) = CS.sampling(matrix, rate, roundId, para) # CS algorithm logger.info('CS estimation...') recoveredMatrix = CS.recover(trainMatrix, observedMatrix, para) plot((matrix[:,30]), '-o') plot(recoveredMatrix[:,30], '-x') show() # sys.exit() runningTime = float(time.clock() - startTime) # evaluate the estimation error evalResult = evallib.evaluate(testMatrix, recoveredMatrix, para) result = (evalResult, runningTime) # dump the result at each rate outFile = '%s%s%s_result_%.2f%s.tmp'%(para['outPath'], para['dataName'], ('_%s'%para['dataType'] if ('dataType' in para.keys()) else ''), rate, '_round%02d'%(roundId + 1) if (para['rounds'] > 1) else '') evallib.dumpresult(outFile, result) logger.info('rate=%.2f, %2d-round done.'%(rate, roundId + 1)) logger.info('----------------------------------------------')
def executeOneSetting(matrix, density, roundId, para): logger.info('density=%.2f, %2d-round starts.'%(density, roundId + 1)) # remove data matrix (trainMatrix, testMatrix) = evallib.removeEntries(matrix, density, roundId) # QoS prediction startTime = time.clock() # to record the running time for one round predictedMatrix = NMF.predict(trainMatrix, para) runningTime = float(time.clock() - startTime) # evaluate the estimation error evalResult = evallib.evaluate(testMatrix, predictedMatrix, para) result = (evalResult, runningTime) # dump the result at each density outFile = '%s%s_%s_result_%.2f_round%02d.tmp'%(para['outPath'], para['dataName'], para['dataType'], density, roundId + 1) evallib.dumpresult(outFile, result) logger.info('density=%.2f, %2d-round done.'%(density, roundId + 1)) logger.info('----------------------------------------------')