Commit f2180794 authored by 高雅喆's avatar 高雅喆

首页接口增加linucb ctr特征的灰度实验

parent bd93be7a
......@@ -232,6 +232,7 @@ class CollectData(object):
def consume_data_from_kafka(self,topic_name=None):
try:
user_feature = [1,1]
# todo 之后用user tag的ctr数据替换
user_feature_ctr = [0.5, 0.5]
kafka_consumer_obj = KafkaManager.get_kafka_consumer_ins(topic_name)
......
......@@ -125,7 +125,10 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
have_read_topic_id_list.extend(useful_topic_id_list)
# linucb 推荐帖子
topic_recommend_redis_key = "physical:linucb:topic_recommend:device_id:" + str(device_id)
if STRATEGY_TYPE.CTR_GRAY in gray_list:
topic_recommend_redis_key = "ctr_physical:linucb:topic_recommend:device_id:" + str(device_id)
else:
topic_recommend_redis_key = "physical:linucb:topic_recommend:device_id:" + str(device_id)
recommend_topic_dict = redis_client.hgetall(topic_recommend_redis_key)
linucb_recommend_topic_id_list = list()
......@@ -257,7 +260,10 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
def get_home_recommend_pictorial_ids(user_id=-1, device_id="", size=4, gray_list=[]):
try:
pictorial_recommend_redis_key = "physical:linucb:pictorial_recommend:device_id:" + str(device_id)
if STRATEGY_TYPE.CTR_GRAY in gray_list:
pictorial_recommend_redis_key = "ctr_physical:linucb:pictorial_recommend:device_id:"+str(device_id)
else:
pictorial_recommend_redis_key = "physical:linucb:pictorial_recommend:device_id:" + str(device_id)
have_read_lin_pictorial_id_list = get_have_read_lin_pictorial_id_list(device_id, user_id,
TopicPageType.HOME_RECOMMEND)
pictorial_recommend_dict = redis_client.hgetall(pictorial_recommend_redis_key)
......
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