Ejemplo n.º 1
0
    def initialize_components(self):

        self.item_cosineCF_recommender = Cosine_Similarity(self.train,
                                                           topK=200,
                                                           shrink=15,
                                                           normalize=True,
                                                           mode='cosine')
        self.user_cosineCF_recommender = Cosine_Similarity(self.train.T,
                                                           topK=200,
                                                           shrink=15,
                                                           normalize=True,
                                                           mode='cosine')
        self.item_bpr_recommender = SLIM_BPR_Cython(self.train,
                                                    positive_threshold=0)
        self.svd_recommender = PureSVDRecommender(self.train)
        self.cbf_bpr_recommender = SLIM_BPR_Cython(self.icm.T,
                                                   positive_threshold=0)
        self.cbf_recommender = Cosine_Similarity(self.icm.T,
                                                 topK=50,
                                                 shrink=10,
                                                 normalize=True,
                                                 mode='cosine')
        if self.ensemble_weights["IALS"] == 0:
            self.ials_recommender = IALS_numpy(iters=0)
        else:
            self.ials_recommender = IALS_numpy()
Ejemplo n.º 2
0
    def fit(self, alpha):
        evaluator_MF = SequentialEvaluator(URM_test_list=self._URM_test, cutoff_list=[10])
        #bprmf = MatrixFactorization_Cython(self._URM_train,
        #                                   positive_threshold=0,
        #                                   algorithm="MF_BPR",
        #                                   )
        # self.MF_BPRW, self.MF_BPRH = bprmf.fit(epochs=200,
        #                                       num_factors=5,
        #                                       batch_size=1,
        #                                       sgd_mode='adagrad'
        #                                       )
        #print(evaluator_MF.evaluateRecommender(bprmf))


        self.bpr_WII = SLIM_BPR_Cython(self._URM_train, positive_threshold=0, symmetric=True).fit(epochs=10,
                                                                                                   topK=200,
                                                                                                    batch_size=200,
                                                                                                   sgd_mode='adagrad',
                                                                                                   learning_rate=1e-2)

        self.bpr_WUU = SLIM_BPR_Cython(self._URM_train.T, positive_threshold=0).fit(epochs=10,
                                                                                    topK=200,
                                                                                    batch_size=200,
                                                                                    sgd_mode='adagrad',
                                                                                    learning_rate=1e-2)

        print(self.bpr_WII)
        print("\n \n max bprII: {0}".format(self.bpr_WII.max()))
        print(self.bpr_WII)
        print("\n \n max bprUU: {0}".format(self.bpr_WUU.max()))
        self._similarity_matrixUU = Cosine_Similarity(self._URM_train.T,
                                                      topK=200,
                                                      shrink=15,
                                                      normalize=True,
                                                      mode='cosine').compute_similarity()
        print("\n \n max uu: {0}".format(self._similarity_matrixUU.max()))

        # self._similarity_matrixII = Cosine_Similarity(self._URM_train.tocsc(),
        #                                              topK=200,
        #                                              shrink=10,
        #                                              normalize=True,
        #                                              mode='cosine').compute_similarity()

        # print("\n \n max II: {0}".format(self._similarity_matrixII.max()))

        self._similarity_matrixCBF = Cosine_Similarity(self._ICM.T,
                                                       topK=10,
                                                       shrink=10,
                                                       normalize=True,
                                                       mode='cosine').compute_similarity()
        # print(self._similarity_matrixII)
        self.latent_x, self.latent_y = (IALS_numpy()).fit(self._URM_train)
        print(self.latent_x.dot(self.latent_y.T))
        print("\n \n max IALS: {0}".format(self.latent_x.dot(self.latent_y.T).max()))
Ejemplo n.º 3
0
    def initialize_components(self):

        self.train = self.rescale_wrt_insertion_order(self.train)

        self.item_cosineCF_recommender = Cosine_Similarity(self.train, topK=200, shrink=15, normalize=True, mode='cosine')
        self.user_cosineCF_recommender = Cosine_Similarity(self.train.T, topK=200, shrink=15, normalize=True, mode='cosine')
        self.svd_recommender = PureSVDRecommender(self.train)
        self.cbf_bpr_recommender = SLIM_BPR_Cython(self.icm.T, positive_threshold=0)
        self.cbf_recommender = Cosine_Similarity(self.icm.T, topK=50, shrink=10, normalize=True, mode='cosine')
        self.item_rp3b_recommender = RP3betaRecommender(self.train)
        self.user_rp3b_recommender = RP3betaRecommender(self.train.T)
        self.bpr_mf = BPR_matrix_factorization(factors=800, regularization=0.01, learning_rate=0.01, iterations=300)
        self.ials_cg_mf = IALS_CG(iterations=15, calculate_training_loss=True, factors=500, use_cg=True, regularization=1e-3)
        self.lightfm = LightFM_Recommender(self.train, self.icm, no_components=200)
Ejemplo n.º 4
0
    def fit(self, k=50, shrink=100, similarity='cosine', normalize=True):

        self.k = k
        self.shrink = shrink

        self.similarity = Cosine_Similarity(self.ICM.T, shrink=shrink, topK=k, normalize=normalize, mode = similarity)


        if self.sparse_weights:
            self.W_sparse = self.similarity.compute_similarity()
        else:
            self.W = self.similarity.compute_similarity()
            self.W = self.W.toarray()