def _load_previously_built_split_and_attributes(self, save_folder_path): """ Loads all URM and ICM :return: """ if self.use_validation_set: validation_set_suffix = "use_validation_set" else: validation_set_suffix = "no_validation_set" if self.allow_cold_users: allow_cold_users_suffix = "allow_cold_users" else: allow_cold_users_suffix = "only_warm_users" name_suffix = "_{}_{}".format(allow_cold_users_suffix, validation_set_suffix) dataIO = DataIO(folder_path=save_folder_path) split_parameters_dict = dataIO.load_data(file_name="split_parameters" + name_suffix) for attrib_name in split_parameters_dict.keys(): self.__setattr__(attrib_name, split_parameters_dict[attrib_name]) self.SPLIT_GLOBAL_MAPPER_DICT = dataIO.load_data(file_name="split_mappers" + name_suffix) self.SPLIT_URM_DICT = dataIO.load_data(file_name="split_URM" + name_suffix) if len(self.dataReader_object.get_loaded_ICM_names()) > 0: self.SPLIT_ICM_DICT = dataIO.load_data(file_name="split_ICM" + name_suffix) self.SPLIT_ICM_MAPPER_DICT = dataIO.load_data(file_name="split_ICM_mappers" + name_suffix)
def _load_previously_built_split_and_attributes(self, save_folder_path): """ Loads all URM and ICM :return: """ if self.allow_cold_users: allow_cold_users_file_name = "allow_cold_users" else: allow_cold_users_file_name = "only_warm_users" data_dict = pickle.load( open(save_folder_path + "URM_{}_fold_split_{}".format(self.n_folds, allow_cold_users_file_name), "rb")) for attrib_name in data_dict.keys(): self.__setattr__(attrib_name, data_dict[attrib_name]) for ICM_name in self.dataReader_object.get_loaded_ICM_names(): ICM_object = pickle.load(open(save_folder_path + "{}".format(ICM_name), "rb")) self.__setattr__(ICM_name, ICM_object) pickle.load(open(save_folder_path + "tokenToFeatureMapper_{}".format(ICM_name), "rb")) self.__setattr__("tokenToFeatureMapper_{}".format(ICM_name), ICM_object) # MAPPER MANAGING if self.allow_cold_users: allow_cold_users_suffix = "allow_cold_users" else: allow_cold_users_suffix = "only_warm_users" name_suffix = "_{}".format(allow_cold_users_suffix) dataIO = DataIO(folder_path=save_folder_path) self.SPLIT_GLOBAL_MAPPER_DICT = dataIO.load_data(file_name="split_mappers" + name_suffix)
def _load_from_saved_sparse_matrix(self, save_folder_path): """ Loads all URM and ICM :return: """ dataIO = DataIO(folder_path=save_folder_path) self._LOADED_GLOBAL_MAPPER_DICT = dataIO.load_data( file_name="dataset_global_mappers") self._LOADED_URM_DICT = dataIO.load_data(file_name="dataset_URM") if len(self.get_loaded_ICM_names()) > 0: self._LOADED_ICM_DICT = dataIO.load_data(file_name="dataset_ICM") self._LOADED_ICM_MAPPER_DICT = dataIO.load_data( file_name="dataset_ICM_mappers")
def load_model(self, folder_path, file_name=None): if file_name is None: file_name = self.RECOMMENDER_NAME self._print("Loading model from file '{}'".format(folder_path + file_name)) dataIO = DataIO(folder_path=folder_path) data_dict = dataIO.load_data(file_name=file_name) for attrib_name in data_dict.keys(): self.__setattr__(attrib_name, data_dict[attrib_name]) self._print("Loading complete")
def _load_from_saved_sparse_matrix(self, save_folder_path): """ Loads all URM, ICM and UCM :return: """ dataIO = DataIO(folder_path=save_folder_path) self._LOADED_GLOBAL_MAPPER_DICT = dataIO.load_data( file_name="dataset_global_mappers") self._LOADED_URM_DICT = dataIO.load_data(file_name="dataset_URM") if len(self.get_loaded_ICM_names()) > 0: self._LOADED_ICM_DICT = dataIO.load_data(file_name="dataset_ICM") self._LOADED_ICM_MAPPER_DICT = dataIO.load_data( file_name="dataset_ICM_mappers") if len(self.get_loaded_UCM_names()) > 0: self._LOADED_UCM_DICT = dataIO.load_data(file_name="dataset_UCM") self._LOADED_UCM_MAPPER_DICT = dataIO.load_data( file_name="dataset_UCM_mappers") print( "RecSys2019Reader: WARNING --> There is no verification in the consistency of UCMs" )