本文整理汇总了Python中sandbox.util.ProfileUtils.ProfileUtils类的典型用法代码示例。如果您正苦于以下问题:Python ProfileUtils类的具体用法?Python ProfileUtils怎么用?Python ProfileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProfileUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: profileObjective
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,代码行数:26,代码来源:MaxLocalAUCCythonProfile.py
示例2: profileDerivativeUiApprox
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,代码行数:34,代码来源:MaxLocalAUCCythonProfile.py
示例3: profileDot2
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,代码行数:7,代码来源:csarrayProfile.py
示例4: profileDot
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,代码行数:32,代码来源:csarrayProfile.py
示例5: profileRunExperiment
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,代码行数:34,代码来源:MovieLensExpProfile.py
示例6: profileModelSelect
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,代码行数:7,代码来源:IterativeSoftImputeProfile.py
示例7: profileEigpsd
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,代码行数:8,代码来源:NystromProfile.py
示例8: profilePutPySparse
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,代码行数:8,代码来源:csarrayProfile.py
示例9: profilePut2
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,代码行数:9,代码来源:csarrayProfile.py
示例10: profileModelSelection
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,代码行数:9,代码来源:ArnetMinerDatasetProfile.py
示例11: profileGenerateSparseBinaryMatrixPL
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,代码行数:9,代码来源:SparseUtilsCythonProfile.py
示例12: profileMC2
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,代码行数:9,代码来源:RankAggregatorProfile.py
示例13: profilePartialReconstructValsPQ
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,代码行数:9,代码来源:SparseUtilsCythonProfile.py
示例14: profileSvd
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,代码行数:9,代码来源:RandomisedSvdProfile.py
示例15: profileSliceSpa
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,代码行数:10,代码来源:csarrayProfile.py
示例16: profileGreedyMethod2
def profileGreedyMethod2(self):
n = 1000
p = 0.1
graph = igraph.Graph.Erdos_Renyi(n, p)
print(graph.summary())
k = 5
numpy.random.seed(21)
ProfileUtils.profile('MaxInfluence.greedyMethod2(graph, k, p=0.5, numRuns=1000)', globals(), locals())
开发者ID:charanpald,项目名称:wallhack,代码行数:10,代码来源:MaxInfluenceProfile.py
示例17: profileSumPys
def profileSumPys(self):
A = spmatrix.ll_mat(self.N, self.N)
A.put(self.val, self.rowInds, self.colInds)
def runSum():
for i in range(1000):
i = PySparseUtils.sum(A)
print(i)
ProfileUtils.profile('runSum()', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:10,代码来源:csarrayProfile.py
示例18: profileSumSpa
def profileSumSpa(self):
A = csarray((self.N, self.N))
A.put(self.val, self.rowInds, self.colInds)
def runSum():
for i in range(1000):
i = A.sum()
print(i)
ProfileUtils.profile('runSum()', globals(), locals())
开发者ID:charanpald,项目名称:sppy,代码行数:10,代码来源:csarrayProfile.py
示例19: profileClusterFromIterator
def profileClusterFromIterator(self):
iterator = IncreasingSubgraphListIterator(self.graph, self.subgraphIndicesList)
dataDir = PathDefaults.getDataDir() + "cluster/"
#iterator = getBemolGraphIterator(dataDir)
def run():
clusterList, timeList, boundList = self.clusterer.clusterFromIterator(iterator, verbose=True)
print(timeList.cumsum(0))
ProfileUtils.profile('run()', globals(), locals())
开发者ID:charanpald,项目名称:sandbox,代码行数:10,代码来源:IterativeSpectralClusteringProfile.py
示例20: profileGetOmegaList
def profileGetOmegaList(self):
shape = (20000, 15000)
r = 50
k = 1000000
X = SparseUtils.generateSparseLowRank(shape, r, k)
import sppy
X = sppy.csarray(X)
ProfileUtils.profile("SparseUtils.getOmegaList(X)", globals(), locals())
开发者ID:kentwang,项目名称:sandbox,代码行数:11,代码来源:SparseUtilsProfile.py
注:本文中的sandbox.util.ProfileUtils.ProfileUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论