[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-07-26。"],[[["\u003cp\u003eCollaborative filtering leverages similarities between users and items to provide recommendations, unlike content-based filtering.\u003c/p\u003e\n"],["\u003cp\u003eThis method allows for serendipitous recommendations by suggesting items based on the preferences of similar users.\u003c/p\u003e\n"],["\u003cp\u003eCollaborative filtering models can automatically learn embeddings, eliminating the need for manual feature engineering.\u003c/p\u003e\n"],["\u003cp\u003eThese embeddings represent users and items in a shared space where their proximity reflects similarity and preference.\u003c/p\u003e\n"],["\u003cp\u003eTraining these models involves optimizing embeddings to align with user feedback, bringing similar users and preferred items closer together in the embedding space.\u003c/p\u003e\n"]]],[],null,["# Collaborative filtering\n\nTo address some of the limitations of content-based filtering,\ncollaborative filtering uses *similarities between users and\nitems simultaneously* to provide recommendations. This allows\nfor serendipitous recommendations; that is, collaborative filtering\nmodels can recommend an item to user A based on the interests of\na similar user B. Furthermore, the embeddings can be learned\nautomatically, without relying on hand-engineering of features.\n\nMovie recommendation example\n----------------------------\n\nConsider a movie recommendation system in which the training data consists\nof a feedback matrix in which:\n\n- Each row represents a user.\n- Each column represents an item (a movie).\n\nThe feedback about movies falls into one of two categories:\n\n- **Explicit**--- users specify how much they liked a particular movie by providing a numerical rating.\n- **Implicit**--- if a user watches a movie, the system infers that the user is interested.\n\nTo simplify, we will assume that the feedback matrix is binary; that is, a value\nof 1 indicates interest in the movie.\n\nWhen a user visits the homepage, the system should recommend movies\nbased on both:\n\n- similarity to movies the user has liked in the past\n- movies that similar users liked\n\nFor the sake of illustration, let's hand-engineer some features for the movies\ndescribed in the following table:\n\n| Movie | [Rating](https://wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system#MPAA_film_ratings) | Description |\n|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [The Dark Knight Rises](http://www.imdb.com/title/tt1345836) | PG-13 | Batman endeavors to save Gotham City from nuclear annihilation in this sequel to [The Dark Knight](http://www.imdb.com/title/tt0468569/), set in the DC Comics universe. |\n| [Harry Potter and the Sorcerer's Stone](http://www.imdb.com/title/tt0241527/) | PG | A orphaned boy discovers he is a wizard and enrolls in Hogwarts School of Witchcraft and Wizardry, where he wages his first battle against the evil Lord Voldemort. |\n| [Shrek](http://www.imdb.com/title/tt0126029/) | PG | A lovable ogre and his donkey sidekick set off on a mission to rescue Princess Fiona, who is emprisoned in her castle by a dragon. |\n| [The Triplets of Belleville](http://www.imdb.com/title/tt0286244) | PG-13 | When professional cycler Champion is kidnapped during the Tour de France, his grandmother and overweight dog journey overseas to rescue him, with the help of a trio of elderly jazz singers. |\n| [Memento](http://www.imdb.com/title/tt0209144/) | R | An amnesiac desperately seeks to solve his wife's murder by tattooing clues onto his body. |\n\n1D embedding\n------------\n\nSuppose we assign to each movie a scalar in \\\\(\\[-1, 1\\]\\\\) that describes\nwhether the movie is for children (negative values) or adults (positive values).\nSuppose we also assign a scalar to each user in \\\\(\\[-1, 1\\]\\\\) that describes\nthe user's interest in children's movies (closer to -1) or adult\nmovies (closer to +1). The product of the movie embedding and the user\nembedding should be higher (closer to 1) for movies that we expect the user\nto like.\n\nIn the diagram below, each checkmark identifies a movie that a particular\nuser watched. The third and fourth users have preferences that are\nwell explained by this feature---the third user prefers movies for children\nand the fourth user prefers movies for adults. However, the first and second\nusers' preferences are not well explained by this single feature.\n\n2D embedding\n------------\n\nOne feature was not enough to explain the preferences of all users. To overcome\nthis problem, let's add a second feature: the degree to which each movie is\na blockbuster or an arthouse movie. With a second feature, we can now represent\neach movie with the following two-dimensional embedding:\n\nWe again place our users in the same embedding space to best explain\nthe feedback matrix: for each (user, item) pair, we would like the\ndot product of the user embedding and the item embedding to be close\nto 1 when the user watched the movie, and to 0 otherwise.\n\n| **Note:** We represented both items and users in the same embedding space. This may seem surprising. After all, users and items are two different entities. However, you can think of the embedding space as an abstract representation common to both items and users, in which we can measure similarity or relevance using a similarity metric.\n\nIn this example, we hand-engineered the embeddings. In practice, the embeddings\ncan be learned *automatically*, which is the power of collaborative filtering\nmodels. In the next two sections, we will discuss different models to learn\nthese embeddings, and how to train them.\n\nThe collaborative nature of this approach is apparent when the model learns the\nembeddings. Suppose the embedding vectors for the movies are fixed. Then,\nthe model can learn an embedding vector for the users to best explain\ntheir preferences. Consequently, embeddings of users with similar preferences\nwill be close together. Similarly, if the embeddings for the users are fixed,\nthen we can learn movie embeddings to best explain the feedback matrix.\nAs a result, embeddings of movies liked by similar users will be close in\nthe embedding space.\n\nCheck your understanding\n------------------------\n\nThe model recommends a shopping app to a user because they recently installed a similar app. What kind of filtering is this an example of? \nContent-based filtering \nGood job! Content-based filtering doesn't look at other users. \nCollaborative filtering \nCollaborative filtering takes other users into consideration. In the given scenario we only care about one user."]]