반응형

from collections import Counter

#15명의 관심사를 리스트로 받음
users_interests = [
["Hadoop", "Big Data", "HBase", "Java", "Spark", "Storm", "Cassandra"],
["NoSQL", "MongoDB", "Cassandra", "HBase", "Postgres"],
["Python", "scikit-learn", "scipy", "numpy", "statsmodels", "pandas"],
["R", "Python", "statistics", "regression", "probability"],
["machine learning", "regression", "decision trees", "libsvm"],
["Python", "R", "Java", "C++", "Haskell", "programming languages"],
["statistics", "probability", "mathematics", "theory"],
["machine learning", "scikit-learn", "Mahout", "neural networks"],
["neural networks", "deep learning", "Big Data", "artificial intelligence"],
["Hadoop", "Java", "MapReduce", "Big Data"],
["statistics", "R", "statsmodels"],
["C++", "deep learning", "artificial intelligence", "probability"],
["pandas", "R", "Python"],
["databases", "HBase", "Postgres", "MySQL", "MongoDB"],
["libsvm", "regression", "support vector machines"]
]

#인기도를 활용한 추천
#단순히 인기 있는 것을 추천하는 방법
popular_interests = Counter(interest
    for user_interests in users_interests
    for interest in user_interests).most_common()

def most_popular_new_interests(user_interests, max_res=5):
    suggestions = [(interest, frequency)
        for interest, frequency in popular_interests
        if interest not in user_interests]
    return suggestions[:max_res]

#사용자 1
most_popular_new_interests(users_interests[1],3)

#사용자 2
most_popular_new_interests(users_interests[3], 3)

반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기