Open lujihong opened 2 years ago
Thank you very much for your reply. Can this score only be in the range of 0.1-1? And can it be 0.01,0.15,0.001... Or something?
In addition, from which dimensions can each user's score be generated, and how many points are appropriate for each generated dimension?
Is there a real project case that can explain how scores are generated and stored? Thank you!
@lujihong
(u1[0.5,0.5], u2[0.7,0.8])
Here is a database diagram for an app that stores user ratings for visited venues. and serves recommendations based on the those ratings.
And here is the function that builds the recommendation service from the ratings, assuming here that I have Model called Rating
Context: the following code snippets are taken from a Laravel app with the following models (User
, Rating
, Venue
)
Venue
HasMany Rating
User
HasMany Rating
Rating
BelongsTo Venue
Rating
BelongsTo User
public function getRecommender() {
foreach (Venue::with(['ratings'])->all() as $venue) {
foreach($venue->ratings as $rating) {
[$venue->id][$rating->user_id] = $rating->rating;
}
}
$recommenderService = new RecommenderService($dataset);
return $recommender = $recommenderService->weightedSlopeone();
}
To get the predictions for the current user here is the function that does that:
public function getPredictions($request) {
$currentUser = $request->user();
$evaluations = [];
foreach ($currentUser->ratings as $rating ) {
$evaluations[$rating->venue_id] = $rating->rating;
}
$recommender = $this->getRecommender();
return $recommender->predict($evaluation);
}
If I manage to get a working laravel example I will attach it here.
Thank you very much for your serious answer. I'll study it and ask you if I don't understand it.
@lujihong great. good luck mate.
Note: I have updated the code to reflect the last version of the package.
sorry for the late reply, here is a quick example:
Now let's say a new user enters your shop and rates the
Intel core i5-12400
with0.4
, you can now predict his ratings for other goods in your shop based on what he already rated, and based on other ratings from other users.