当前位置: 首页>>代码示例>>Python>>正文


Python ProfileUtils.profile方法代码示例

本文整理汇总了Python中sandbox.util.ProfileUtils.ProfileUtils.profile方法的典型用法代码示例。如果您正苦于以下问题:Python ProfileUtils.profile方法的具体用法?Python ProfileUtils.profile怎么用?Python ProfileUtils.profile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sandbox.util.ProfileUtils.ProfileUtils的用法示例。


在下文中一共展示了ProfileUtils.profile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: profileObjective

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
    def profileObjective(self):

        k = 10
        U = numpy.random.rand(self.m, k)
        V = numpy.random.rand(self.n, k)

        indPtr, colInds = SparseUtils.getOmegaListPtr(self.X)
        colIndsProbabilities = numpy.ones(colInds.shape[0])

        for i in range(self.m):
            colIndsProbabilities[indPtr[i] : indPtr[i + 1]] /= colIndsProbabilities[indPtr[i] : indPtr[i + 1]].sum()
            colIndsProbabilities[indPtr[i] : indPtr[i + 1]] = numpy.cumsum(
                colIndsProbabilities[indPtr[i] : indPtr[i + 1]]
            )

        r = numpy.zeros(self.m)
        lmbda = 0.001
        rho = 1.0
        numAucSamples = 100

        def run():
            numRuns = 10
            for i in range(numRuns):
                objectiveApprox(indPtr, colInds, indPtr, colInds, U, V, r, numAucSamples, lmbda, rho, False)

        ProfileUtils.profile("run()", globals(), locals())
开发者ID:kentwang,项目名称:sandbox,代码行数:28,代码来源:MaxLocalAUCCythonProfile.py

示例2: profileDerivativeUiApprox

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
    def profileDerivativeUiApprox(self):
        k = 10
        U = numpy.random.rand(self.m, k)
        V = numpy.random.rand(self.n, k)

        indPtr, colInds = SparseUtils.getOmegaListPtr(self.X)

        gp = numpy.random.rand(self.n)
        gp /= gp.sum()
        gq = numpy.random.rand(self.n)
        gq /= gq.sum()

        j = 3
        numRowSamples = 100
        numAucSamples = 10

        permutedRowInds = numpy.array(numpy.random.permutation(self.m), numpy.uint32)
        permutedColInds = numpy.array(numpy.random.permutation(self.n), numpy.uint32)

        maxLocalAuc = MaxLocalAUC(k, w=0.9)
        normGp, normGq = maxLocalAuc.computeNormGpq(indPtr, colInds, gp, gq, self.m)

        lmbda = 0.001
        normalise = True

        learner = MaxLocalAUCCython()

        def run():
            numRuns = 10
            for j in range(numRuns):
                for i in range(self.m):
                    learner.derivativeUiApprox(indPtr, colInds, U, V, gp, gq, permutedColInds, i)

        ProfileUtils.profile("run()", globals(), locals())
开发者ID:kentwang,项目名称:sandbox,代码行数:36,代码来源:MaxLocalAUCCythonProfile.py

示例3: profileDot2

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileDot2(self): 
     density = 0.01
     m = 10000
     n = 10000
     a_sppy = sppy.rand((m, n), density, storagetype='row')
     a_sppy_T = sppy.csarray(a_sppy.T, storagetype="col")
     ProfileUtils.profile('a_sppy.dot(a_sppy_T)', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:9,代码来源:csarrayProfile.py

示例4: profileDot

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileDot(self): 
     #Create random sparse matrix and numpy array 
     #Test speed of array creation 
     numpy.random.seed(21)
     m = 1000000
     n = 1000000      
     numInds = 10000000
     
     inds = numpy.random.randint(0, m*n, numInds)
     inds = numpy.unique(inds)
     vals = numpy.random.randn(inds.shape[0])
     
     rowInds, colInds = numpy.unravel_index(inds, (m, n), order="FORTRAN")
     rowInds = numpy.array(rowInds, numpy.int32)
     colInds = numpy.array(colInds, numpy.int32)
             
     A = csarray((m, n), storageType="rowMajor")
     A.put(vals, rowInds, colInds, True)
     A.compress()
     
     p = 500
     W = numpy.random.rand(n, p)
     
     
     ProfileUtils.profile('A.dot(W)', globals(), locals())
     
     #Compare versus scipy 
     #B = scipy.sparse.csc_matrix((vals, (rowInds, colInds)), (m, n))        
     #ProfileUtils.profile('B.dot(W)', globals(), locals())
     
     #Compare versus pdot       
     ProfileUtils.profile('A.pdot(W)', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:34,代码来源:csarrayProfile.py

示例5: profileRunExperiment

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileRunExperiment(self):
     
     def run(): 
         dataArgs = argparse.Namespace()
         dataArgs.maxIter = 3 
         #Set iterStartDate to None for all iterations 
         #dataArgs.iterStartTimeStamp = None 
         dataArgs.iterStartTimeStamp = time.mktime(datetime(2005,1,1).timetuple())
         generator = MovieLensDataset(maxIter=dataArgs.maxIter, iterStartTimeStamp=dataArgs.iterStartTimeStamp)        
         
         defaultAlgoArgs = argparse.Namespace()
         defaultAlgoArgs.ks = numpy.array(2**numpy.arange(6, 7, 0.5), numpy.int)
         defaultAlgoArgs.svdAlgs = ["rsvd"]   
         defaultAlgoArgs.runSoftImpute = True
         
         dataParser = argparse.ArgumentParser(description="", add_help=False)
         dataParser.add_argument("-h", "--help", action="store_true", help="show this help message and exit")
         devNull, remainingArgs = dataParser.parse_known_args(namespace=dataArgs)
         
         dataArgs.extendedDirName = ""
         dataArgs.extendedDirName += "MovieLensDataset"
         
         recommendExpHelper = RecommendExpHelper(generator.getTrainIteratorFunc, generator.getTestIteratorFunc, remainingArgs, defaultAlgoArgs, dataArgs.extendedDirName)
         recommendExpHelper.printAlgoArgs()
         #    os.makedirs(resultsDir, exist_ok=True) # for python 3.2
         try:
             os.makedirs(recommendExpHelper.resultsDir)
         except OSError as err:
             if err.errno != errno.EEXIST:
                 raise
         
         recommendExpHelper.runExperiment()
         
     ProfileUtils.profile('run()', globals(), locals())    
开发者ID:charanpald,项目名称:wallhack,代码行数:36,代码来源:MovieLensExpProfile.py

示例6: profileModelSelect

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileModelSelect(self):
     lmbdas = numpy.linspace(1.0, 0.01, 5)
     softImpute = IterativeSoftImpute(k=500)
     
     folds = 5
     cvInds = Sampling.randCrossValidation(folds, self.X.nnz)
     ProfileUtils.profile('softImpute.modelSelect(self.X, lmbdas, cvInds)', globals(), locals())
开发者ID:charanpald,项目名称:sandbox,代码行数:9,代码来源:IterativeSoftImputeProfile.py

示例7: profileEigpsd

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileEigpsd(self):
     n = 1000 
     p = 0.1 
     L = scipy.sparse.rand(n, n, p)            
     L = L.T.dot(L)
         
     cols = 500
     ProfileUtils.profile('Nystrom.eigpsd(L, cols)', globals(), locals())
开发者ID:charanpald,项目名称:sandbox,代码行数:10,代码来源:NystromProfile.py

示例8: profilePutPySparse

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profilePutPySparse(self): 
     
     def runPut(): 
         A = spmatrix.ll_mat(self.N, self.N)
         for i in range(self.k):         
             A.put(self.val, self.rowInds, self.colInds)
     
     ProfileUtils.profile('runPut()', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:10,代码来源:csarrayProfile.py

示例9: profilePut2

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profilePut2(self):
     def runPut(): 
         
         for i in range(self.k):         
             A = csarray((self.N, self.N))
             #A[(self.rowInds, self.colInds)] = self.val 
             A.put(self.val, self.rowInds, self.colInds)
     
     ProfileUtils.profile('runPut()', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:11,代码来源:csarrayProfile.py

示例10: profileModelSelection

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileModelSelection(self): 
     dataset = ArnetMinerDataset(runLSI=False)   
     dataset.overwrite = True
     dataset.overwriteVectoriser = True
     dataset.overwriteModel = True
     
     dataset.dataFilename = dataset.dataDir + "DBLP-citation-100000.txt"
     
     ProfileUtils.profile('dataset.modelSelection()', globals(), locals())
开发者ID:charanpald,项目名称:wallhack,代码行数:11,代码来源:ArnetMinerDatasetProfile.py

示例11: profileGenerateSparseBinaryMatrixPL

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileGenerateSparseBinaryMatrixPL(self): 
     m = 500 
     n = 200 
     k = 10
     density = 0.2
     numpy.random.seed(21)
     #X = SparseUtils.generateSparseBinaryMatrixPL((m,n), k, density=density, csarray=True)   
     
     ProfileUtils.profile('SparseUtilsCython.generateSparseBinaryMatrixPL((m,n), k, density=density, csarray=True)', globals(), locals()) 
开发者ID:charanpald,项目名称:sandbox,代码行数:11,代码来源:SparseUtilsCythonProfile.py

示例12: profileMC2

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileMC2(self): 
     numVals = 10000
     list1 = numpy.random.permutation(numVals).tolist()      
     list2 = numpy.random.permutation(numVals).tolist()   
     lists = [list1, list2]
     
     itemList = numpy.arange(numVals).tolist()
     
     ProfileUtils.profile('RankAggregator.MC2(lists, itemList)', globals(), locals())  
开发者ID:charanpald,项目名称:wallhack,代码行数:11,代码来源:RankAggregatorProfile.py

示例13: profilePartialReconstructValsPQ

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profilePartialReconstructValsPQ(self):
     shape = 5000, 10000
     r = 100 
     U, s, V = SparseUtils.generateLowRank(shape, r)
     
     k = 1000000 
     inds = numpy.unravel_index(numpy.random.randint(0, shape[0]*shape[1], k), dims=shape)
     
     ProfileUtils.profile('SparseUtilsCython.partialReconstructValsPQ(inds[0], inds[1], U, V)', globals(), locals())
开发者ID:charanpald,项目名称:sandbox,代码行数:11,代码来源:SparseUtilsCythonProfile.py

示例14: profileSvd

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileSvd(self):
     n = 5000 
     p = 0.1 
     L = scipy.sparse.rand(n, n, p)            
     L = L.T.dot(L)
         
     k = 50 
     q = 2
     ProfileUtils.profile('RandomisedSVD.svd(L, k, q)', globals(), locals())
开发者ID:charanpald,项目名称:sandbox,代码行数:11,代码来源:RandomisedSvdProfile.py

示例15: profileSliceSpa

# 需要导入模块: from sandbox.util.ProfileUtils import ProfileUtils [as 别名]
# 或者: from sandbox.util.ProfileUtils.ProfileUtils import profile [as 别名]
 def profileSliceSpa(self): 
     A = csarray((self.N, self.N))
     A.put(self.val, self.rowInds, self.colInds)
     
     def runSlice():     
         for i in range(10):  
             sliceInds = numpy.array(numpy.random.randint(0, self.M, self.N), dtype=numpy.int)
             B = A[:, sliceInds]
         
     ProfileUtils.profile('runSlice()', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:12,代码来源:csarrayProfile.py


注:本文中的sandbox.util.ProfileUtils.ProfileUtils.profile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。