Documentation ¶
Index ¶
- func CalculateRecommendationProbabilities(currentUserID uint, unreviewedResources []uint, similarUsers map[uint]float64) map[uint]float64
- func CalculateSimilaritiesWithOtherUsers(currentUserID uint, similarUsers []uint, ...) (sims map[uint]float64, err error)
- func CalculateUserSimilarity(...) (similarityCoefficient float64)
- func GetLikersDislikersForResource(resourceID uint) ([]uint, []uint, error)
- func GetUnreviewedResources(currentUserID uint) ([]uint, error)
- func GetUserLikesDislikes(userID uint) (liked []uint, notLiked []uint, err error)
- func GetUsersWhoDislikedResource(resourceID uint) ([]uint, error)
- func GetUsersWhoLikedResource(resourceID uint) ([]uint, error)
- func GetUsersWhoReviewedResource(resourceID uint) (userslist []uint, err error)
- func GetUsersWithSimilarInteractions(likedResources []uint, dislikedResources []uint, userID uint) (userslist []uint, err error)
- type Recommendation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateRecommendationProbabilities ¶
func CalculateRecommendationProbabilities(currentUserID uint, unreviewedResources []uint, similarUsers map[uint]float64) map[uint]float64
CalculateRecommendationProbabilities returns mapping on user's unreviewed resources to the "probability" of them liking it (i.e., order of recommendation).
ZL = sum of similarity coefficients of other similar users who have liked a particular resource.
ML = number of such users as above
ZD = sum of similarity coefficients of other similar users who have disliked a particular resource.
MD = number of such users as above
P(U, B) = (ZL - ZD) / (|ML| + |MD|)
Produces a value between -1 and 1
func CalculateSimilaritiesWithOtherUsers ¶
func CalculateSimilaritiesWithOtherUsers(currentUserID uint, similarUsers []uint, currentUserLiked, currentUserDisliked []uint) (sims map[uint]float64, err error)
CalculateSimilaritiesWithOtherUsers returns a mapping of similar users (returned by GetUsersWithSimilarInteractions) to their similarity coefficient with current user.
func CalculateUserSimilarity ¶
func CalculateUserSimilarity(currentUserLiked, currentUserDisliked, otherUserLiked, otherUserDisliked []uint) (similarityCoefficient float64)
CalculateUserSimilarity of two users via modified Jaccard Coefficient.
S(U1, U2) = (|L1 intersec L2| + |D1 intersect D2| - |L1 intersect D2| - |L2 intersect D1|) / |L1 union L2 union D1 union D2|
func GetUnreviewedResources ¶
GetUnreviewedResources fetches resources which the current user has not yet reviewed (will select recommendations from among these)
func GetUserLikesDislikes ¶
GetUserLikesDislikes retrieves the resource IDs that a user has liked and disliked based on their review ratings. It queries the database for reviews associated with the given user ID and categorizes the resources into liked and disliked lists.
func GetUsersWhoReviewedResource ¶
GetUsersWhoReviewedResource retrieves the user IDs of users who have reviewed a specific resource. It queries the database for reviews associated with the given resource ID and returns the user IDs of users who have reviewed the resource.
func GetUsersWithSimilarInteractions ¶
func GetUsersWithSimilarInteractions(likedResources []uint, dislikedResources []uint, userID uint) (userslist []uint, err error)
GetUsersWithSimilarInteractions retrieves user IDs who have interacted with resources that are similar to the given user's liked and disliked resources. It queries the database for users who have reviewed resources that match the liked and disliked resources of the given user.
Types ¶
type Recommendation ¶
func GetRecommendedResourcesSortedAndPaginated ¶
func GetRecommendedResourcesSortedAndPaginated(recommendationProbabilities map[uint]float64, page int, perPage int) []Recommendation