Commit ca0f2dde authored by 郭羽's avatar 郭羽

update feature

parent e41bc4ed
...@@ -339,8 +339,8 @@ def featuresToRedis(samples,columns,prefix,redisKey): ...@@ -339,8 +339,8 @@ def featuresToRedis(samples,columns,prefix,redisKey):
k = d[idCol] k = d[idCol]
v = json.dumps(d.asDict(), ensure_ascii=False) v = json.dumps(d.asDict(), ensure_ascii=False)
newKey = redisKey + k newKey = redisKey + k
conn.set(newKey, v) # conn.set(newKey, v)
conn.expire(newKey, 60 * 60 * 24 * 7) # conn.expire(newKey, 60 * 60 * 24 * 7)
#根据timestamp获取每个user最新的记录 #根据timestamp获取每个user最新的记录
prefixSamples = samples.groupBy(idCol).agg(F.max("timestamp").alias(timestampCol)) prefixSamples = samples.groupBy(idCol).agg(F.max("timestamp").alias(timestampCol))
...@@ -813,14 +813,13 @@ if __name__ == '__main__': ...@@ -813,14 +813,13 @@ if __name__ == '__main__':
# model columns # model columns
print("model columns to redis...") print("model columns to redis...")
model_columns = user_columns + item_columns model_columns = user_columns + item_columns
featureColumnsToRedis(model_columns) # featureColumnsToRedis(model_columns)
print("数据字典save...") print("数据字典save...")
print("dataVocab:", str(dataVocab.keys())) print("dataVocab:", str(dataVocab.keys()))
vocab_path = "../vocab/{}_vocab.json".format(VERSION) vocab_path = "../vocab/{}_vocab.json".format(VERSION)
dataVocabStr = json.dumps(dataVocab, ensure_ascii=False) dataVocabStr = json.dumps(dataVocab, ensure_ascii=False)
open(configUtils.VOCAB_PATH, mode='w', encoding='utf-8').write(dataVocabStr) # open(configUtils.VOCAB_PATH, mode='w', encoding='utf-8').write(dataVocabStr)
# dataVocabToRedis(dataVocabStr)
"""特征数据存入redis======================================""" """特征数据存入redis======================================"""
# user特征数据存入redis # user特征数据存入redis
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment