-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement similarity recommendation based on goods? Can you write an example? #9
Comments
sorry for the late reply, here is a quick example: $dataset = [
"Intel core i5-12400" => [
"user1" => 1,
"user2" => 1,
"user3" => 0.2,
],
"Intel core i5-12900k" => [
"user1" => 0.5,
"user3" => 0.4,
"user4" => 0.9,
],
"Ryzen 5 5600x" => [
"user1" => 0.2,
"user2" => 0.5,
"user3" => 1,
"user4" => 0.4,
],
"Asus Prime B660" => [
"user2" => 0.2,
"user3" => 0.4,
"user4" => 0.5,
],
];
$recommenderService = new RecommenderService($dataset);
$recommender = $recommenderService->weightedSlopeone(); // WeightedSlopeone recommender Now let's say a new user enters your shop and rates the // Predict future ratings
$results = $recommender->predict([
"Intel core i5-12400" => 0.4
]);
[
"Intel core i5-12900k" => 0.25,
"Ryzen 5 5600x" => 0.23,
"Asus Prime B660" => 0.1
]; |
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! |
|
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 Context: the following code snippets are taken from a Laravel app with the following models (
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.
|
No description provided.
The text was updated successfully, but these errors were encountered: