Tìm điểm tương đồng

Xây dựng Recommendation Engine bằng Python

Rob O'Callaghan

Director of Data

Gợi ý dựa trên mục

Xây dựng Recommendation Engine bằng Python

Gợi ý dựa trên mục

Xây dựng Recommendation Engine bằng Python

Gợi ý dựa trên mục

Xây dựng Recommendation Engine bằng Python

Từ dựa trên người dùng sang dựa trên mục

Xây dựng Recommendation Engine bằng Python

Từ dựa trên người dùng sang dựa trên mục

Xây dựng Recommendation Engine bằng Python

Từ dựa trên người dùng sang dựa trên mục

print(user_ratings_pivot):
          The Great Gatsby    The Catcher in the Rye    Fifty Shades of Grey                    
User_233               0.0                       0.0                     0.0
User_651               0.0                       0.5                    -0.5
User_965               0.5                      -0.5                     0.0
     ...               ...                       ...                     ...
book_ratings_pivot = user_ratings_pivot.T
print(book_ratings_pivot)
                  User_233                  User_651                User_965                    
The Great Gatsby       0.0                       0.0                     0.5
The Catcher in the Rye 0.0                       0.5                    -0.5
Fifty Shades of Grey   0.0                      -0.5                     0.0
                 ...   ...                       ...                     ...
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

book_ratings_pivot:

                  User_233                  User_651                User_965                    
The Great Gatsby       0.0                       0.0                     0.5
The Catcher in the Rye 0.0                       0.5                    -0.5
Fifty Shades of Grey   0.0                      -0.5                     0.0
                 ...   ...                       ...                     ...
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

cosine_similarity(                                                                    ,
                                                                               )
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

cosine_similarity(book_ratings_pivot.loc['Lord of the Rings', :]                      ,
                  book_ratings_pivot.loc['The Hobbit', :]                      )
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

cosine_similarity(book_ratings_pivot.loc['Lord of the Rings', :].values               ,
                  book_ratings_pivot.loc['The Hobbit', :].values               )
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

cosine_similarity(book_ratings_pivot.loc['Lord of the Rings', :].values.reshape(1, -1),
                  book_ratings_pivot.loc['The Hobbit', :].values.reshape(1, -1))
0.43
cosine_similarity(book_ratngs.loc['Lord of the Rings', :].values.reshape(1, -1),
                  book_ratngs.loc['Twilight', :].values.reshape(1, -1))
-0.64
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

similarities = cosine_similarity(book_ratings_pivot)

cosine_similarity_df = pd.DataFrame(book_ratings_pivot, index=book_ratings_pivot.index, columns=book_ratings_pivot.index)
cosine_similarity_df.head()
          The Great Gatsby    The Catcher in the Rye    Fifty Shades of Grey                    
The Great Gatsby       1.0                       0.0                    -0.3
The Catcher in the Rye 0.0                       1.0                    -0.5
Fifty Shades of Grey  -0.3                      -0.5                     1.0
                 ...   ...                       ...                     ...
Xây dựng Recommendation Engine bằng Python

Độ tương đồng cosine

cosine_similarity_series = cosine_similarity_df.loc['The Hobbit']

ordered_similarities = cosine_similarity_series.sort_values(ascending=False)
print(ordered_similarities)
The Hobbit         1.00
Lord of the Rings  0.43
The Silmarillion   0.37
...
Xây dựng Recommendation Engine bằng Python

Ayo berlatih!

Xây dựng Recommendation Engine bằng Python

Preparing Video For Download...