การค้นหาความคล้ายคลึง

การสร้าง Recommendation Engine ด้วย Python

Rob O'Callaghan

Director of Data

การแนะนำตามรายการ

การสร้าง Recommendation Engine ด้วย Python

การแนะนำตามรายการ

การสร้าง Recommendation Engine ด้วย Python

การแนะนำตามรายการ

การสร้าง Recommendation Engine ด้วย Python

จากผู้ใช้สู่รายการ

การสร้าง Recommendation Engine ด้วย Python

จากผู้ใช้สู่รายการ

การสร้าง Recommendation Engine ด้วย Python

จากผู้ใช้สู่รายการ

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
                 ...   ...                       ...                     ...
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

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
                 ...   ...                       ...                     ...
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

cosine_similarity(                                                                    ,
                                                                               )
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

cosine_similarity(book_ratings_pivot.loc['Lord of the Rings', :]                      ,
                  book_ratings_pivot.loc['The Hobbit', :]                      )
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

cosine_similarity(book_ratings_pivot.loc['Lord of the Rings', :].values               ,
                  book_ratings_pivot.loc['The Hobbit', :].values               )
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

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
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

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
                 ...   ...                       ...                     ...
การสร้าง Recommendation Engine ด้วย Python

Cosine Similarity

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
...
การสร้าง Recommendation Engine ด้วย Python

มาฝึกกันเถอะ!

การสร้าง Recommendation Engine ด้วย Python

Preparing Video For Download...