def func2(): data = pd.read_csv('./data/train.csv') data = data[['user_id','brand_id','type','month','day']] data = np.array(data) user_id = func.read('user_id') item_id = func.read('item_id') user_item_time = func.build_user_item_time(data,user_id) item_time = itemmodel.build_item_time(data,item_id) item_factor = itemmodel.cal_item_time_factor(item_time) func.write(user_item_time,'user_item_time') func.write(item_time,'item_time') return (user_item_time,item_time,item_factor)
def func3(): train,test = func.divide_data() user_id = func.read('user_id') item_id = func.read('item_id') train_u_i_t = func.build_user_item_time(train,user_id) #建立测试集的用户-物品词典,这里不需要时间序列 test_u_i = func.build_user_item(test,user_id) #建立训练集的物品-时间词典 train_item_time = itemmodel.build_item_time(train,item_id) #建立物品的时间衰减因子 item_factor = itemmodel.cal_item_time_factor(train_item_time) func.write(train_u_i_t,'train_user_item_time') func.write(test_u_i,'test_user_item') func.write(train_item_time,'train_item_time') return (train_u_i_t,test_u_i,train_item_time,item_factor)