示例#1
0
 def profileLearnModel(self):
     #Profile full gradient descent 
     u = 0.2
     w = 1-u
     eps = 10**-6
     alpha = 0.5
     learner = BprRecommender(self.k)
     learner.maxIterations = 10
     learner.recordStep = 10
     learner.numAucSamples = 5
     print(learner)
     print(self.X.nnz)
             
     ProfileUtils.profile('learner.learnModel(self.X)', globals(), locals())
示例#2
0
 def testLearnModel(self): 
     m = 50 
     n = 20 
     k = 5
     u = 0.1 
     w = 1-u
     X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w, csarray=True)
     
     lmbda = 0.1 
     gamma = 0.01
     learner = BprRecommender(k, lmbda, gamma)
     learner.max_iters = 50
     
     learner.learnModel(X)
     Z = learner.predict(n)
示例#3
0
    def testLearnModel(self):
        m = 50
        n = 20
        k = 5
        u = 0.1
        w = 1 - u
        X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w, csarray=True)

        lmbda = 0.1
        gamma = 0.01
        learner = BprRecommender(k, lmbda, gamma)
        learner.max_iters = 50

        learner.learnModel(X)
        Z = learner.predict(n)
示例#4
0
    def testModelSelect(self):
        m = 50
        n = 50
        k = 5
        u = 0.5
        w = 1 - u
        X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w)

        os.system('taskset -p 0xffffffff %d' % os.getpid())

        u = 0.2
        lmbda = 0.1
        gamma = 0.01
        learner = BprRecommender(k, lmbda, gamma)
        learner.maxIterations = 2
        learner.ks = 2**numpy.arange(3, 5)
        learner.lmbdaUsers = 2.0**-numpy.arange(1, 3)
        learner.lmbdaPoses = 2.0**-numpy.arange(1, 3)
        learner.lmbdaNegs = 2.0**-numpy.arange(1, 3)
        learner.gammas = 2.0**-numpy.arange(1, 3)
        learner.folds = 2
        learner.numProcesses = 1

        colProbs = numpy.array(X.sum(1)).ravel()
        colProbs /= colProbs.sum()
        print(colProbs, colProbs.shape)

        learner.modelSelect(X, colProbs=colProbs)
示例#5
0
 def testModelSelect(self): 
     m = 50 
     n = 50 
     k = 5
     u = 0.5 
     w = 1-u
     X = SparseUtils.generateSparseBinaryMatrix((m, n), k, w)
     
     os.system('taskset -p 0xffffffff %d' % os.getpid())
     
     u = 0.2
     lmbda = 0.1 
     gamma = 0.01
     learner = BprRecommender(k, lmbda, gamma)
     learner.maxIterations = 2        
     learner.ks = 2**numpy.arange(3, 5)
     learner.lmbdaUsers = 2.0**-numpy.arange(1, 3)
     learner.lmbdaPoses = 2.0**-numpy.arange(1, 3)
     learner.lmbdaNegs = 2.0**-numpy.arange(1, 3)
     learner.gammas = 2.0**-numpy.arange(1, 3)
     learner.folds = 2
     learner.numProcesses = 1 
     
     colProbs = numpy.array(X.sum(1)).ravel()
     colProbs /= colProbs.sum()
     print(colProbs, colProbs.shape)
     
     learner.modelSelect(X, colProbs=colProbs)