recommender

package
v0.0.0-...-eea28b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

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 GetLikersDislikersForResource

func GetLikersDislikersForResource(resourceID uint) ([]uint, []uint, error)

func GetUnreviewedResources

func GetUnreviewedResources(currentUserID uint) ([]uint, error)

GetUnreviewedResources fetches resources which the current user has not yet reviewed (will select recommendations from among these)

func GetUserLikesDislikes

func GetUserLikesDislikes(userID uint) (liked []uint, notLiked []uint, err error)

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 GetUsersWhoDislikedResource

func GetUsersWhoDislikedResource(resourceID uint) ([]uint, error)

func GetUsersWhoLikedResource

func GetUsersWhoLikedResource(resourceID uint) ([]uint, error)

func GetUsersWhoReviewedResource

func GetUsersWhoReviewedResource(resourceID uint) (userslist []uint, err error)

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

type Recommendation struct {
	Resource    models.Resource
	Probability float64
}

func GetRecommendedResourcesSortedAndPaginated

func GetRecommendedResourcesSortedAndPaginated(recommendationProbabilities map[uint]float64, page int, perPage int) []Recommendation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL