Ejemplo n.º 1
0
 def recommend(self, uids):
     print 'Recommending'
     bestMethod = self.best_alg()
     alg = AlgFactory.create(bestMethod)
     alg.fit(self.samples, self.targets)
     recommendList = []
     for u in uids:
         recommendList.append(alg.recommend(u))
     return recommendList
Ejemplo n.º 2
0
 def recommendAll(self):
     print 'Recommending'
     # bestMethod = self.best_alg()
     # alg = AlgFactory.create(bestMethod)
     alg = AlgFactory.create('ItemCF')
     uids = list(set(np.array(self.samples)[:,0]))
     alg.fit(self.samples, self.targets)
     recommendList = []
     for u in uids:
         rec = alg.recommend(u)
         rec.insert(0, u)
         recommendList.append(rec)
     t = pd.DataFrame(recommendList)
     t.to_csv('rec_list')
Ejemplo n.º 3
0
    def mulProcess(self,result,processParameters):
        algName = processParameters[0]
        parameters = processParameters[1]
        alg = AlgFactory.create(algName)

        rec_cv =  StratifiedKFold(self.labels, 2)
        clf = grid_search.GridSearchCV(alg, parameters, cv=rec_cv)
        clf.fit(self.samples, self.targets)
        print(clf.best_estimator_)
        print(clf.grid_scores_)
        self.Lock.acquire()
        result.append(algName)
        result.append([clf.best_estimator_,clf.best_score_])
        result.append(clf.grid_scores_)
        self.Lock.release()