def ad_cosine_sim(ads1, ads2): # check ad_union = ads1.union(ads2) vec1 = [] vec2 = [] for ad in ad_union.data: vec1.append(ads1.ad_weight(ad, W_CHOICE)) vec2.append(ads2.ad_weight(ad, W_CHOICE)) return common.cosine_sim(vec1, vec2)
def news_cosine_sim(newsv1, newsv2): # check news_union = newsv1.union(newsv2) vec1 = [] vec2 = [] for news in news_union.data: vec1.append(newsv1.news_weight(news, W_CHOICE)) vec2.append(newsv2.news_weight(news, W_CHOICE)) return common.cosine_sim(vec1, vec2)