def __init__(self, data: DataObject):
     super(Hybrid100AlphaRecommender, self).__init__(data.urm_train)
     self.data = data
     self.rec1 = UserKNNCBFRecommender(data.ucm_all, data.urm_train)
     self.rec2 = MatrixFactorization_AsySVD_Cython(data.urm_train)
     self.random_seed = data.random_seed
     try:
         self.rec1.load_model(
             "stored_recommenders/user_cbf/",
             f"{self.random_seed}_topK=5000_shrink=5_feature_weighting=TF-IDF_similarity=euclidean"
         )
     except:
         self.rec1.fit(topK=5000,
                       shrink=5,
                       feature_weighting="TF-IDF",
                       similarity="euclidean")
         self.rec1.save_model(
             "stored_recommenders/user_cbf/",
             f"{self.random_seed}_topK=5000_shrink=5_feature_weighting=TF-IDF_similarity=euclidean"
         )
     self.rec2.load_model("Hybrid", "AsySVD")
     cold = data.ids_cold_user
     train_cold = data.urm_train_users_by_type[0][1]
     # if train_cold.shape[0] > 0:
     #     target_users = np.append(cold, train_cold)
     # else:
     #     target_users = cold
     target_users = data.ids_user
     self.hybrid_rec = Hybrid1CXAlphaRecommender(
         data,
         recommenders=[self.rec1, self.rec2],
         recommended_users=target_users,
         max_cutoff=30)
def trial_inter(data):
    rec = UserKNNCBFRecommender(UCM=data.ucm_interaction, URM_train=data.urm_train)
    rec.fit()
    for n, users, description in data.urm_train_users_by_type:
        eval, map = MyEvaluator.evaluate_algorithm(data.urm_test, users, rec, at=10, remove_top=0)
        print(f"\t {description},\t {eval}")
    print(MyEvaluator.evaluate_algorithm(data.urm_test, data.ids_warm_user, rec))
class Hybrid001AlphaRecommender(BaseRecommender):
    """Hybrid001AlphaRecommender recommender"""

    RECOMMENDER_NAME = "Hybrid001AlphaRecommender"

    def __init__(self, URM_train, UCM, cold_users, warm_users):
        super(Hybrid001AlphaRecommender, self).__init__(URM_train)
        self.warm_recommender = ItemKNNCFRecommender(URM_train)
        self.cold_recommender = UserKNNCBFRecommender(UCM, URM_train)
        self.cold_users = cold_users
        self.warm_users = warm_users

    def fit(self):
        self.warm_recommender.fit(topK=12, shrink=16)
        self.cold_recommender.fit(topK=11000, shrink=2)

    def recommend(self,
                  user_id_array,
                  cutoff=None,
                  remove_seen_flag=True,
                  items_to_compute=None,
                  remove_top_pop_flag=False,
                  remove_CustomItems_flag=False,
                  return_scores=False):
        if user_id_array in self.warm_users:
            return self.warm_recommender.recommend(user_id_array,
                                                   cutoff=cutoff)
        if user_id_array in self.cold_users:
            return self.cold_recommender.recommend(user_id_array,
                                                   cutoff=cutoff)
    def __init__(self, urm_train, eurm=False):
        super(HybridGenRecommender, self).__init__(urm_train)

        self.data_folder = Path(__file__).parent.parent.absolute()

        self.eurm = eurm

        self.num_users = urm_train.shape[0]
        data = DataManager()

        urm_train = check_matrix(urm_train.copy(), 'csr')
        icm_price, icm_asset, icm_sub, icm_all = data.get_icm()
        ucm_age, ucm_region, ucm_all = data.get_ucm()

        recommender_1 = ItemKNNCBFRecommender(urm_train, icm_all)
        recommender_1.fit(shrink=40, topK=20, feature_weighting='BM25')

        # recommender_2 = UserKNNCBFRecommender(urm_train, ucm_all)
        # recommender_2.fit(shrink=500, topK=1600, normalize=True)

        recommender_2 = UserKNNCBFRecommender(urm_train, ucm_all)
        recommender_2.fit(shrink=1777,
                          topK=1998,
                          similarity='tversky',
                          feature_weighting='BM25',
                          tversky_alpha=0.1604953616,
                          tversky_beta=0.9862348646)

        self.recommender_1 = recommender_1
        self.recommender_2 = recommender_2
    def single_test(urm_train, urm_test, urm_valid):
        evaluator_valid = EvaluatorHoldout(urm_valid, cutoff_list=[10])
        evaluator_test = EvaluatorHoldout(urm_test, cutoff_list=[10])

        recommender = UserKNNCBFRecommender(urm_train, ucm_all)
        recommender.fit(shrink=1777,
                        topK=1998,
                        similarity='tversky',
                        feature_weighting='BM25',
                        tversky_alpha=0.1604953616,
                        tversky_beta=0.9862348646)

        result, str_result = evaluator_test.evaluateRecommender(recommender)
        # result, str_result = evaluator_valid.evaluateRecommender(recommender)
        # res[num_test] = result[10]['MAP']
        return result[10]['MAP']
Пример #6
0
    def __init__(self, urm_train):
        super(HybridZeroRecommender, self).__init__(urm_train)

        urm_train = check_matrix(urm_train.copy(), 'csr')

        data = DataManager()

        ucm_age, ucm_region, ucm_all = data.get_ucm()

        recommender_1 = TopPop(urm_train)
        recommender_1.fit()
        #
        recommender_2 = UserKNNCBFRecommender(urm_train, ucm_all)
        recommender_2.fit(shrink=500, topK=1600, similarity='tversky')

        self.recommender_1 = recommender_1
        self.recommender_2 = recommender_2
Пример #7
0
class Hybrid000AlphaRecommender(BaseRecommender):
    """Hybrid000AlphaRecommender recommender"""

    RECOMMENDER_NAME = "Hybrid000AlphaRecommender"

    def __init__(self, URM_train, UCM, cold_users, warm_users):
        super(Hybrid000AlphaRecommender, self).__init__(URM_train)
        self.warm_recommender = SLIM_BPR_Cython(URM_train)
        self.cold_recommender = UserKNNCBFRecommender(UCM, URM_train)
        self.cold_users = cold_users
        self.warm_users = warm_users

    def fit(self,
            random_seed=42,
            epochs=500,
            topK=14000,
            shrink=2,
            lambda_i=0.0,
            lambda_j=0.0):
        self.warm_recommender.fit(epochs=epochs,
                                  lambda_i=lambda_i,
                                  lambda_j=lambda_j,
                                  random_seed=random_seed)
        self.cold_recommender.fit(topK=topK,
                                  shrink=shrink,
                                  feature_weighting="BM25")

    def recommend(self,
                  user_id_array,
                  cutoff=None,
                  remove_seen_flag=True,
                  items_to_compute=None,
                  remove_top_pop_flag=False,
                  remove_CustomItems_flag=False,
                  return_scores=False):
        if user_id_array in self.warm_users:
            return self.warm_recommender.recommend(user_id_array,
                                                   cutoff=cutoff)
        if user_id_array in self.cold_users:
            return self.cold_recommender.recommend(user_id_array,
                                                   cutoff=cutoff)
Пример #8
0
 def __init__(self, data: DataObject):
     super(Hybrid100AlphaRecommender, self).__init__(data.urm_train)
     self.data = data
     self.rec1 = UserKNNCBFRecommender(data.ucm_all, data.urm_train)
     self.rec2 = TopPop(data.urm_train)
     self.rec1.fit(topK=5000,
                   shrink=5,
                   feature_weighting="TF-IDF",
                   similarity="euclidean")
     self.rec2.fit()
     cold = data.ids_cold_user
     train_cold = data.urm_train_users_by_type[0][1]
     if train_cold.shape[0] > 0:
         target_users = np.append(cold, train_cold)
     else:
         target_users = cold
     self.target_users = target_users
     self.hybrid_rec = Hybrid1CXAlphaRecommender(
         data,
         recommenders=[self.rec1, self.rec2],
         recommended_users=target_users,
         max_cutoff=20)
class Hybrid100AlphaRecommender(BaseRecommender):
    """Hybrid100AlphaRecommender recommender"""

    RECOMMENDER_NAME = "Hybrid100AlphaRecommender"

    def __init__(self, data: DataObject):
        super(Hybrid100AlphaRecommender, self).__init__(data.urm_train)
        self.data = data
        self.rec1 = UserKNNCBFRecommender(data.ucm_all, data.urm_train)
        self.rec2 = MatrixFactorization_AsySVD_Cython(data.urm_train)
        self.random_seed = data.random_seed
        try:
            self.rec1.load_model(
                "stored_recommenders/user_cbf/",
                f"{self.random_seed}_topK=5000_shrink=5_feature_weighting=TF-IDF_similarity=euclidean"
            )
        except:
            self.rec1.fit(topK=5000,
                          shrink=5,
                          feature_weighting="TF-IDF",
                          similarity="euclidean")
            self.rec1.save_model(
                "stored_recommenders/user_cbf/",
                f"{self.random_seed}_topK=5000_shrink=5_feature_weighting=TF-IDF_similarity=euclidean"
            )
        self.rec2.load_model("Hybrid", "AsySVD")
        cold = data.ids_cold_user
        train_cold = data.urm_train_users_by_type[0][1]
        # if train_cold.shape[0] > 0:
        #     target_users = np.append(cold, train_cold)
        # else:
        #     target_users = cold
        target_users = data.ids_user
        self.hybrid_rec = Hybrid1CXAlphaRecommender(
            data,
            recommenders=[self.rec1, self.rec2],
            recommended_users=target_users,
            max_cutoff=30)

    def fit(self):
        weights = [
            [
                0.7609041954308008, 0.27339862890657357, 0.3144084232425596,
                0.28678002559795207, 0.3170292366001356, 0.24147239220026245,
                0.14009508172349497, 0.15649320080818696, 0.16743130156581199,
                0.18707405544524536, 0.19350324993686288, 0.21987953364962454,
                0.2233212596556791, 0.19217500924897687, 0.19736284590367756,
                0.2100228313521805, 0.18526521644738797, 0.19299238737073587,
                0.12892725272565625, 0.12007519721696268, 0.08916255488946315,
                0.09565831116101862, 0.08921835911617365, 0.09575012944298913,
                0.06061814295035001, 0.06788462944119182, 0.037165855793027704,
                0.04105324668609332, 0.023576935696646744, 0.0
            ],
            [
                1.0, 0.23662052508936088, 0.2225837530904237,
                0.2536834803952595, 0.2917360024545484, 0.20844068794221393,
                0.11251972620359912, 0.10895216412067295, 0.11738478513380732,
                0.10458147363449094, 0.10786698616858342, 0.11776718227577632,
                0.10415827006216491, 0.10285083017703549, 0.11514393572529961,
                0.07647362838535736, 0.08649824797408665, 0.0906695206756817,
                0.07494150129954372, 0.06680458369333378, 0.06642942053751508,
                0.06459816503682635, 0.07336768255019717, 0.030660821531648116,
                0.027881710157031087, 0.019316732889272565,
                0.02139829161607211, 0.024608035358482924,
                0.016094537787800765, 0.010481732651884517
            ]
        ]
        # weights = [[20.75, 12., 15.25, 12.25, 9.75, 12.25, 8.5, 5., 8.5,
        #             9.75, 8.25, 5., 4.75, 7.25, 6.75, 6.25, 8., 8.,
        #             9.5, 7.25, 8.75, 8.25, 6.75, 10.25, 12.25, 8., 8.5,
        #             10., 7.75, 6.5],
        #            [11., 13., 10., 5.25, 7.5, 10., 9.25, 9., 4.,
        #             12.5, 10.75, 11.75, 14., 8.5, 6.5, 6.5, 3.75, 1.75,
        #             6.25, 7.25, 6.25, 8.5, 1.75, 7., 5.5, 6.25, 5.5,
        #             4.25, 3., 4.5]]
        self.hybrid_rec.weights = weights

    def recommend(self,
                  user_id_array,
                  cutoff=None,
                  remove_seen_flag=True,
                  items_to_compute=None,
                  remove_top_pop_flag=False,
                  remove_CustomItems_flag=False,
                  return_scores=False):
        return self.hybrid_rec.recommend(user_id_array=user_id_array,
                                         cutoff=cutoff)
Пример #10
0
    def __init__(self, urm_train, eurm=False):
        super(HybridNormOrigRecommender, self).__init__(urm_train)
        self.data_folder = Path(__file__).parent.parent.absolute()
        self.eurm = eurm
        self.num_users = urm_train.shape[0]

        data = DataManager()

        urm_train = check_matrix(urm_train.copy(), 'csr')
        icm_price, icm_asset, icm_sub, icm_all = data.get_icm()
        ucm_age, ucm_region, ucm_all = data.get_ucm()

        recommender_1 = ItemKNNCBFRecommender(urm_train, icm_all)
        recommender_1.fit(shrink=40, topK=20, feature_weighting='BM25')

        recommender_7 = UserKNNCBFRecommender(urm_train, ucm_all)
        recommender_7.fit(shrink=1777,
                          topK=1998,
                          similarity='tversky',
                          feature_weighting='BM25',
                          tversky_alpha=0.1604953616,
                          tversky_beta=0.9862348646)

        # recommender_1 = HybridGenRecommender(urm_train, eurm=self.eurm)
        # recommender_1.fit()

        # recommender_2 = ItemKNNCFRecommender(urm_train)
        # recommender_2.fit(shrink=30, topK=20)

        recommender_2 = ItemKNNCFRecommender(urm_train)
        recommender_2.fit(topK=5,
                          shrink=500,
                          feature_weighting='BM25',
                          similarity='tversky',
                          normalize=False,
                          tversky_alpha=0.0,
                          tversky_beta=1.0)

        recommender_3 = UserKNNCFRecommender(urm_train)
        recommender_3.fit(shrink=2, topK=600, normalize=True)
        # recommender_3 = UserKNNCFRecommender(urm_train)
        # recommender_3.fit(topK=697, shrink=1000, feature_weighting='TF-IDF', similarity='tversky', normalize=False,
        #                   tversky_alpha=1.0, tversky_beta=1.0)

        recommender_4 = RP3betaRecommender(urm_train)
        recommender_4.fit(topK=16,
                          alpha=0.03374950051351756,
                          beta=0.24087176329409027,
                          normalize_similarity=False)

        recommender_5 = SLIM_BPR_Cython(urm_train)
        recommender_5.fit(lambda_i=0.0926694015,
                          lambda_j=0.001697250,
                          learning_rate=0.002391,
                          epochs=65,
                          topK=200)

        recommender_6 = ALSRecommender(urm_train)
        recommender_6.fit(alpha=5, iterations=40, reg=0.3)

        self.recommender_1 = recommender_1
        self.recommender_2 = recommender_2
        self.recommender_3 = recommender_3
        self.recommender_4 = recommender_4
        self.recommender_5 = recommender_5
        self.recommender_6 = recommender_6
        self.recommender_7 = recommender_7

        if self.eurm:

            if Path(self.data_folder / 'Data/uicm_orig_sparse.npz').is_file():
                print("Previous uicm_sparse found")
                self.score_matrix_1 = sps.load_npz(self.data_folder /
                                                   'Data/uicm_sparse.npz')
            else:
                print("uicm_sparse not found, create new one...")
                self.score_matrix_1 = self.recommender_1._compute_item_matrix_score(
                    np.arange(self.num_users))
                sps.save_npz(self.data_folder / 'Data/uicm_orig_sparse.npz',
                             self.score_matrix_1)

            self.score_matrix_2 = self.recommender_2._compute_item_matrix_score(
                np.arange(self.num_users))
            self.score_matrix_3 = self.recommender_3._compute_item_matrix_score(
                np.arange(self.num_users))
            self.score_matrix_4 = self.recommender_4._compute_item_matrix_score(
                np.arange(self.num_users))
            self.score_matrix_5 = self.recommender_5._compute_item_matrix_score(
                np.arange(self.num_users))
            self.score_matrix_6 = self.recommender_6._compute_item_score(
                np.arange(self.num_users))

            self.score_matrix_1 = normalize(self.score_matrix_2,
                                            norm='max',
                                            axis=1)
            self.score_matrix_2 = normalize(self.score_matrix_2,
                                            norm='max',
                                            axis=1)
            self.score_matrix_3 = normalize(self.score_matrix_3,
                                            norm='max',
                                            axis=1)
            self.score_matrix_4 = normalize(self.score_matrix_4,
                                            norm='max',
                                            axis=1)
            self.score_matrix_5 = normalize(self.score_matrix_5,
                                            norm='max',
                                            axis=1)
            self.score_matrix_6 = normalize(self.score_matrix_6,
                                            norm='max',
                                            axis=1)
        #
        #     if result_dict[10]["MAP"] > best_res:
        #         best_alpha = alpha
        #         best_res = result_dict[10]["MAP"]
        #
        # print('The alpha is {}'.format(best_alpha))
        #
        # pyplot.plot(x_tick, MAP_per_k_valid)
        # pyplot.ylabel('MAP_valid')
        # pyplot.xlabel('alpha')
        # pyplot.show()
        #
        # recommender = UserKNNCBFRecommender(urm_train, ucm_all)
        # recommender.fit(shrink=500, topK=1600, similarity='tversky')

        recommender = UserKNNCBFRecommender(urm_train, ucm_all)
        recommender.fit(shrink=1777,
                        topK=1998,
                        similarity='tversky',
                        feature_weighting='BM25',
                        tversky_alpha=0.1604953616,
                        tversky_beta=0.9862348646)

        # recommender = UserKNNCBFRecommender(urm_train, ucm_all)
        # recommender.fit(shrink=979, topK=1677, similarity='jaccard')
        #
        # recommender = UserKNNCBFRecommender(urm_train, ucm_all)
        # recommender.fit(shrink=1000, topK=1700, similarity='tanimoto', normalize=False)

        # recommender_3 = UserKNNCFRecommender(urm_train)
        # recommender_3.fit(shrink=2, topK=600, normalize=True)
 def __init__(self, URM_train, UCM, cold_users, warm_users):
     super(Hybrid001AlphaRecommender, self).__init__(URM_train)
     self.warm_recommender = ItemKNNCFRecommender(URM_train)
     self.cold_recommender = UserKNNCBFRecommender(UCM, URM_train)
     self.cold_users = cold_users
     self.warm_users = warm_users
                         alpha=1e-6,
                         beta=0.2,
                         min_rating=0)

recommenderUserKNN = UserKNNCFRecommender(URM_all)
recommenderUserKNN.fit(topK=550,
                       shrink=0,
                       similarity='jaccard',
                       normalize=True)

recommenderIALS = IALSRecommender(URM_all)
# recommenderIALS.fit(epochs=200, alpha=1, reg=1e-4)
# recommenderIALS.save_model('model/', file_name='IALS_1_200_max')
recommenderIALS.load_model('model/', file_name='IALS_1_200_max')

recommenderUserCBF = UserKNNCBFRecommender(URM_all, UCM_all)
recommenderUserCBF.fit(topK=3000,
                       shrink=10,
                       similarity='cosine',
                       normalize=True)

hybridRecommender = ItemKNNScoresHybridRecommender(
    URM_all, itemKNNCF, recommenderELASTIC, recommenderCB,
    recommenderBetaGRAPH, recommenderUserKNN, recommenderCYTHON,
    recommenderIALS)

hybridRecommender_semiCold = ItemKNNScoresHybridRecommender(
    URM_all, itemKNNCF, recommenderELASTIC, recommenderCB,
    recommenderBetaGRAPH, recommenderUserKNN, recommenderCYTHON,
    recommenderIALS)
Пример #14
0
class Hybrid100AlphaRecommender(BaseRecommender):
    """Hybrid100AlphaRecommender recommender"""

    RECOMMENDER_NAME = "Hybrid100AlphaRecommender"

    def __init__(self, data: DataObject):
        super(Hybrid100AlphaRecommender, self).__init__(data.urm_train)
        self.data = data
        self.rec1 = UserKNNCBFRecommender(data.ucm_all, data.urm_train)
        self.rec2 = TopPop(data.urm_train)
        self.rec1.fit(topK=5000,
                      shrink=5,
                      feature_weighting="TF-IDF",
                      similarity="euclidean")
        self.rec2.fit()
        cold = data.ids_cold_user
        train_cold = data.urm_train_users_by_type[0][1]
        if train_cold.shape[0] > 0:
            target_users = np.append(cold, train_cold)
        else:
            target_users = cold
        self.target_users = target_users
        self.hybrid_rec = Hybrid1CXAlphaRecommender(
            data,
            recommenders=[self.rec1, self.rec2],
            recommended_users=target_users,
            max_cutoff=20)

    def fit(self):
        weights = [
            [
                1.0, 0.6821568252468901, 0.6849024969656253,
                0.5278884115166208, 0.5256279588345396, 0.3523944402333277,
                0.35917072524518867, 0.3781483902477164, 0.35494012640675526,
                0.2569761057765945, 0.2686708563615972, 0.26047695765786827,
                0.18963922521929752, 0.19796884202620682, 0.21062192323921447,
                0.21086230330374983, 0.20645211181144751, 0.2051545899987307,
                0.195630375727827, 0.16433006044601312, 0.15898416104687418,
                0.13710408424057147, 0.14535409877804073, 0.14093706131152708,
                0.13925057012140438, 0.10897116615151631, 0.08690310920352357,
                0.05452137761633189, 0.039626490480693964, 0.038884188246590415
            ],
            [
                0.12184895015208339, 0.10412792995227525, 0.11245816434845729,
                0.09237425432552643, 0.07790937226904884, 0.08414212205057275,
                0.06899821248751226, 0.07451806948651324, 0.06080223143736178,
                0.05923095707738565, 0.0639694336435765, 0.06890447942434409,
                0.06474046677091937, 0.0672866612162612, 0.06627995889505314,
                0.06170959010489348, 0.05576908741213118, 0.05516680106058056,
                0.04913346628366165, 0.042346032068023606, 0.04268540340456829,
                0.03738588109631485, 0.03801703741074155, 0.03634930102905383,
                0.027148968808256298, 0.023744038897221154,
                0.019516056544059187, 0.009815556133702266,
                0.0038914891192522562, 0.0034155098002848494
            ]
        ]
        self.hybrid_rec.weights = weights

    def recommend(self,
                  user_id_array,
                  cutoff=None,
                  remove_seen_flag=True,
                  items_to_compute=None,
                  remove_top_pop_flag=False,
                  remove_CustomItems_flag=False,
                  return_scores=False):
        if user_id_array in self.target_users:
            return self.hybrid_rec.recommend(user_id_array=user_id_array,
                                             cutoff=cutoff)
        else:
            return []
Пример #15
0
 def __init__(self, URM_train, UCM, cold_users, warm_users):
     super(Hybrid000AlphaRecommender, self).__init__(URM_train)
     self.warm_recommender = SLIM_BPR_Cython(URM_train)
     self.cold_recommender = UserKNNCBFRecommender(UCM, URM_train)
     self.cold_users = cold_users
     self.warm_users = warm_users
    def __init__(self, urm_train, eurm=False):
        super(HybridGen2Recommender, self).__init__(urm_train)
        self.eurm = eurm
        self.data_folder = Path(__file__).parent.parent.absolute()

        self.num_users = urm_train.shape[0]

        urm_train = check_matrix(urm_train.copy(), 'csr')

        data = DataManager()

        if Path(self.data_folder /
                'Data/icm_sparse.npz').is_file() and self.eurm:
            print("Previous icm_sparse found")
        else:
            _, _, _, icm_all = data.get_icm()

            args = {
                'topK': 6,
                'shrink': 5,
                'feature_weighting': 'TF-IDF',
                'similarity': 'cosine',
                'normalize': False
            }

            recommender_1 = ItemKNNCBFRecommender(urm_train, icm_all)
            recommender_1.fit(**args)
            self.recommender_1 = recommender_1

        if Path(self.data_folder /
                'Data/ucm_sparse.npz').is_file() and self.eurm:
            print("Previous ucm_sparse found")
        else:
            ucm_age, ucm_region, ucm_all = data.get_ucm()
            recommender_2 = UserKNNCBFRecommender(urm_train, ucm_all)
            recommender_2.fit(shrink=1777,
                              topK=1998,
                              similarity='tversky',
                              feature_weighting='BM25',
                              tversky_alpha=0.1604953616,
                              tversky_beta=0.9862348646)
            self.recommender_2 = recommender_2

        if self.eurm:
            beta = 0.6
            if Path(self.data_folder / 'Data/icm_sparse.npz').is_file():
                self.score_matrix_1 = sps.load_npz(self.data_folder /
                                                   'Data/icm_sparse.npz')
            else:
                print("icm_sparse not found, create new one...")
                self.score_matrix_1 = self.recommender_1._compute_item_matrix_score(
                    np.arange(self.num_users))
                user_score_matrix_1 = normalize(self.score_matrix_1,
                                                norm='max',
                                                axis=1)
                item_score_matrix_1 = normalize(self.score_matrix_1.tocsc(),
                                                norm='max',
                                                axis=0)
                self.score_matrix_1 = item_score_matrix_1 * beta + user_score_matrix_1.tocsr(
                ) * (1 - beta)
                sps.save_npz(self.data_folder / 'Data/icm_sparse.npz',
                             self.score_matrix_1)

            if Path(self.data_folder / 'Data/ucm_sparse.npz').is_file():
                self.score_matrix_2 = sps.load_npz(self.data_folder /
                                                   'Data/ucm_sparse.npz')
            else:
                print("ucm_sparse not found, create new one...")
                self.score_matrix_2 = self.recommender_2._compute_item_matrix_score(
                    np.arange(self.num_users))
                user_score_matrix_2 = normalize(self.score_matrix_2,
                                                norm='max',
                                                axis=1)
                item_score_matrix_2 = normalize(self.score_matrix_2.tocsc(),
                                                norm='max',
                                                axis=0)
                self.score_matrix_2 = item_score_matrix_2 * beta + user_score_matrix_2.tocsr(
                ) * (1 - beta)
                sps.save_npz(self.data_folder / 'Data/ucm_sparse.npz',
                             self.score_matrix_2)
        # TODO: Edit here
        # TODO: If you edit here, remember to edit at the end too
        # Insert the mix of recommender systems
        rec1 = UserKNNCFRecommender(datas[j].urm_train)
        rec1.fit(shrink=1000,
                 topK=1000,
                 similarity="cosine",
                 feature_weighting="TF-IDF")
        rec2 = RP3betaRecommender(datas[j].urm_train)
        rec2.fit(topK=5000, alpha=0.35, beta=0.025, implicit=True)
        rec3 = ItemKNNCFRecommender(datas[j].urm_train)
        rec3.fit(topK=200,
                 shrink=1000,
                 similarity="jaccard",
                 feature_weighting="TF-IDF")
        rec4 = UserKNNCBFRecommender(datas[j].ucm_all, datas[j].urm_train)
        rec4.fit(topK=5000,
                 shrink=5,
                 feature_weighting="TF-IDF",
                 similarity="euclidean")
        rec5 = ItemKNNCBFRecommender(datas[j].urm_train,
                                     datas[j].icm_all_augmented)
        rec5.fit(topK=100,
                 shrink=1,
                 feature_weighting="TF-IDF",
                 similarity="cosine")
        base_recommenders.append([rec1, rec2, rec3, rec4, rec5])

        # TODO: Edit here
        # Insert the type of users to test the recommenders
        n, t_users, description = datas[j].urm_train_users_by_type[1]