def data_initial(path_global, path_user, user, Sc, resultpath): if not os.path.exists(os.path.join(resultpath, 'tmpdata')): os.mkdir(os.path.join(resultpath, 'tmpdata')) if os.path.exists(os.path.join(resultpath, 'tmpdata', user + 'list.npy')): print('data-initial of userdata from exist data...') userlist = np.load( os.path.join(resultpath, 'tmpdata', user + 'list.npy')) userdata = np.load( os.path.join(resultpath, 'tmpdata', user + 'data.npy')) D_user = {userlist[i]: userdata[i] for i in range(len(userlist))} else: feature_user = [os.path.join(path_user, user)] D_user = modules.feature_user(feature_user, Sc) List = [k for k in D_user] Data = [D_user[List[i]] for i in range(len(List))] np.save(os.path.join(resultpath, 'tmpdata', user + 'list.npy'), List) np.save(os.path.join(resultpath, 'tmpdata', user + 'data.npy'), Data) path_globalData = os.path.join(resultpath, 'tmpdata', 'data_global.npy') if os.path.exists(path_globalData): data_global = np.load(path_globalData) r_all = data_global[0] r_sc_all = list(data_global[1:1 + len(Sc)]) r_time_all = list(data_global[-len(config_model.T):]) else: file_global = os.listdir(path_global) feature_global = [ os.path.join(path_global, path) for path in file_global ] r_all, r_sc_all, r_time_all = modules.feature_global( feature_global, config_model) data_global = [r_all] + r_sc_all + r_time_all np.save(path_globalData, data_global) return r_all, r_sc_all, r_time_all, D_user
def data_initial(path_global, path_user, users, path_userData='userData'): if os.path.exists(path_userData): print('data-initial of userdata from exist data...') userlist = np.load(path_userData + '/' + users[0] + 'list.npy') userdata = np.load(path_userData + '/' + users[0] + 'data.npy', allow_pickle=True) D_user = {userlist[i]: userdata[i] for i in range(len(userlist))} else: feature_user = [os.path.join(path_user, path) for path in users] D_user = modules.feature_user(feature_user) path_globalData = os.path.join(resultpath, 'tmpdata', 'data_global.npy') if os.path.exists(path_globalData): data_global = np.load(path_globalData) r_all = data_global[0] r_sc_all = list(data_global[1:1 + len(Sc)]) r_time_all = list(data_global[-len(config_model.T):]) else: file_global = os.listdir(path_global) feature_global = [ os.path.join(path_global, path) for path in file_global ] r_all, r_sc_all, r_time_all = modules.feature_global( feature_global, config_model) data_global = [r_all] + r_sc_all + r_time_all np.save(path_globalData, data_global) r_sc_all = np.array(r_sc_all) r_time_all = np.array(r_time_all) return r_all, r_sc_all, r_time_all, D_user
def data_initial(path_global, path_user, users, path_userData='userData'): config_global = modelconfig() file_global = os.listdir(path_global) feature_global = [os.path.join(path_global, path) for path in file_global] feature_user = [os.path.join(path_user, path) for path in users] r_all, r_sc_all, r_time_all = modules.feature_global( feature_global, config_global) if os.path.exists(path_userData): print('data-initial of userdata from exist data...') userlist = np.load(path_userData + '/' + users[0] + 'list.npy') userdata = np.load(path_userData + '/' + users[0] + 'data.npy') D_user = {userlist[i]: userdata[i] for i in range(len(userlist))} else: D_user = modules.feature_user(feature_user) return r_all, r_sc_all, r_time_all, D_user