Slope One implementation option offers poor recommendations

I am trying to implement the Slope One algorithm through PHP for a custom member recommendation. For this, I use the OpenSlopeOne library . The problem I am facing is that the recommendations created are not related to the user.

I currently have two tables: user_ratings and slope_one. The user_ratings table is pretty straight forward. It contains the rating of each item given by this user (user_id, item_id and user_item_rating). The slope_one table follows the default OpenSlopeOne schema: item_id1, item_id2, time, and rating.

The slope_one table is populated using the following SQL procedure:

CREATE PROCEDURE `slope_one`()
begin                    
    DECLARE tmp_item_id int;
    DECLARE done int default 0;                    
    DECLARE mycursor CURSOR FOR select distinct item_id from user_ratings;
    DECLARE CONTINUE HANDLER FOR NOT FOUND set done=1;
    open mycursor;
    while (!done) do
        fetch mycursor into tmp_item_id;
        if (!done) then
            insert into slope_one (select a.item_id as item_id1,b.item_id as item_id2,count(*) as times, sum(a.rating-b.rating) as rating from user_ratings a, user_ratings b where a.item_id = tmp_item_id and b.item_id != a.item_id and a.user_id=b.user_id group by a.item_id,b.item_id);
        end if;
    END while;
    close mycursor;
end

, :

SELECT
    item.* 
FROM
    slope_one s,
    user_ratings u,
    item
WHERE 
    u.user_id = '{USER_ID}' AND 
    s.item_id1 = u.item_id AND 
    s.item_id2 != u.item_id AND
    item.id = s.item_id2
GROUP BY 
    s.item_id2 
ORDER BY
    SUM(u.rating * s.times - s.rating) / SUM(s.times) DESC
LIMIT 20

, , , . (10 000+ ), . , , .

+3
2

(, .)

, - , . - - , , .

, , 100% - . A B , u, : (r_uB - r_uA). , , ( ) B, A: (r_uB) - (r_uA). (B) (A) .

P . A P , A B; ( (P) - (A)), ( (B) - (A)). P diffs B ( (P) - (B)).

, , P . , , , , P (, , ) . .

, , , - . "" ( P !), , .

Daniel Lemire , , , "" "" . .

, Apache Mahout, . , , , . , . , .

+5
+1

Source: https://habr.com/ru/post/1790251/


All Articles