Commit ffab6059 authored by 郭羽's avatar 郭羽

update feature

parent ca0f2dde
......@@ -339,8 +339,8 @@ def featuresToRedis(samples,columns,prefix,redisKey):
k = d[idCol]
v = json.dumps(d.asDict(), ensure_ascii=False)
newKey = redisKey + k
# conn.set(newKey, v)
# conn.expire(newKey, 60 * 60 * 24 * 7)
conn.set(newKey, v)
conn.expire(newKey, 60 * 60 * 24 * 7)
#根据timestamp获取每个user最新的记录
prefixSamples = samples.groupBy(idCol).agg(F.max("timestamp").alias(timestampCol))
......@@ -813,13 +813,13 @@ if __name__ == '__main__':
# model columns
print("model columns to redis...")
model_columns = user_columns + item_columns
# featureColumnsToRedis(model_columns)
featureColumnsToRedis(model_columns)
print("数据字典save...")
print("dataVocab:", str(dataVocab.keys()))
vocab_path = "../vocab/{}_vocab.json".format(VERSION)
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)
"""特征数据存入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