Esempio n. 1
0
            CoLinUCBPicked = None
            LinUCB_maxPTA = float('-inf')
            LinUCBPicked = None
            GOBLin_maxPTA = float('-inf')
            GOBLinPicked = None

            currentUserID = userID
            if currentUserID >= userNum:
                continue
            else:
                article_chosen = int(pool_articles[0])
                # for article in np.random.permutation(pool_articles) :
                for article in pool_articles:
                    article_id = int(article.strip(']'))
                    # print article_id
                    article_featureVector = getFeatureVector(LastFM_FeatureVectorsFileName, article_id)
                    article_featureVector = np.array(article_featureVector, dtype=float)
                    # print article_featureVector
                    currentArticles.append(article_id)
                    # CoLinUCB pick article
                    if len(article_featureVector) == 25:
                        # print 'Yes'
                        CoLinUCB_pta = CoLinUCB_USERS.getProb(alpha, article_featureVector, currentUserID)
                        # print article_id, CoLinUCB_pta
                        if CoLinUCB_maxPTA < CoLinUCB_pta:
                            CoLinUCBPicked = article_id  # article picked by CoLinUCB
                            CoLinUCB_PickedfeatureVector = article_featureVector
                            CoLinUCB_maxPTA = CoLinUCB_pta
                            # print CoLinUCBPicked
                        LinUCB_pta = LinUCB_users[currentUserID].getProb(alpha, article_featureVector)
                        if LinUCB_maxPTA < LinUCB_pta:
Esempio n. 2
0
  CoLinUCBPicked = None  
  LinUCB_maxPTA = float('-inf')  
  LinUCBPicked = None  
  GOBLin_maxPTA = float('-inf')
  GOBLinPicked = None  
 
  currentUserID = userID
  if currentUserID >= userNum:
      continue
  else:  
      article_chosen = int(pool_articles[0])  
      #for article in np.random.permutation(pool_articles) :
      for article in pool_articles:
          article_id = int(article.strip(']'))
          #print article_id
          article_featureVector = getFeatureVector(Delicious_FeatureVectorsFileName, article_id)
          #print article_featureVector
          article_featureVector =np.array(article_featureVector,dtype=float)
          #print article_featureVector
          currentArticles.append(article_id)
          # CoLinUCB pick article
          if len(article_featureVector)==25:
              #print 'Yes'
              CoLinUCB_pta = CoLinUCB_USERS.getProb(alpha, article_featureVector, currentUserID)
              #print article_id, CoLinUCB_pta
              if CoLinUCB_maxPTA < CoLinUCB_pta:
                  CoLinUCBPicked = article_id    # article picked by CoLinUCB
                  CoLinUCB_PickedfeatureVector = article_featureVector
                  CoLinUCB_maxPTA = CoLinUCB_pta
              LinUCB_pta = LinUCB_users[currentUserID].getProb(alpha, article_featureVector)
              if LinUCB_maxPTA < LinUCB_pta:
Esempio n. 3
0
  CoLinUCBPicked = None  
  LinUCB_maxPTA = float('-inf')  
  LinUCBPicked = None  
  GOBLin_maxPTA = float('-inf')
  GOBLinPicked = None  
 
  currentUserID = userID
  if currentUserID >= userNum:
      continue
  else:  
      article_chosen = int(pool_articles[0])  
      #for article in np.random.permutation(pool_articles) :
      for article in pool_articles:
          article_id = int(article.strip(']'))
          #print article_id
          article_featureVector = getFeatureVector(LastFM_FeatureVectorsFileName, article_id)
          article_featureVector =np.array(article_featureVector ,dtype=float)
          #print article_featureVector
          currentArticles.append(article_id)
          # CoLinUCB pick article
          if len(article_featureVector)==25:
              #print 'Yes'
              CoLinUCB_pta = CoLinUCB_USERS.getProb(alpha, article_featureVector, currentUserID)
              #print article_id, CoLinUCB_pta
              if CoLinUCB_maxPTA < CoLinUCB_pta:
                  CoLinUCBPicked = article_id    # article picked by CoLinUCB
                  CoLinUCB_PickedfeatureVector = article_featureVector
                  CoLinUCB_maxPTA = CoLinUCB_pta
                  #print CoLinUCBPicked
              LinUCB_pta = LinUCB_users[currentUserID].getProb(alpha, article_featureVector)
              if LinUCB_maxPTA < LinUCB_pta: