joelgrus / data-science-from-scratch

code for Data Science From Scratch book
MIT License
8.71k stars 4.52k forks source link

Fix "most_common_interests_with" function in introduction #97

Open luizfsf2 opened 4 years ago

luizfsf2 commented 4 years ago

https://github.com/joelgrus/data-science-from-scratch/blob/d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1/first-edition/code-python3/introduction.py#L118

def most_common_interests_with(user_id):
    return Counter([interested_user_id
        for interest in interests_by_user_id[user_id]
        for interested_user_id in user_ids_by_interest[interest]
        if interested_user_id != user_id])