You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Item:User x User:Item 그래프로 Item:Item 그래프 생성droptable if exists tmp_p3_iter1;
createtabletmp_p3_iter1asselect item_index1, item_index2, prob
from (
select
item_index1, item_index2, prob, row_number() over (partition by item_index1 order by prob desc) as rank
from
(
selecta.item_indexas item_index1,
b.item_indexas item_index2,
sum(a.prob*b.prob) as prob
from tmp_p3_graph a
inner join tmp_p3_graph b
ona.user_index=b.user_indexanda.item_index!=b.item_indexgroup bya.item_index, b.item_index
) a
) a
where rank <=100;
여기서 sum(a.prob * b.prob) as prob 하는 부분이 있는데, a는 item → user 역할이고 b는 user → item 역할이기 때문에 b에선 user_prob을 가져오는게 맞지 않나요? a에선 P(user|item)를, b에선 P(item|user)를 담당해주기 때문이라고 생각했습니다.
감사합니다.
The text was updated successfully, but these errors were encountered:
sum(a.prob * b.prob)으로 계산했을 경우, item_index1로 GROUP BY해서, 즉 row의 합을 구해보면 1을 훌쩍 넘게 됩니다.
지금은 random walk 중이니까 row-stochastic 조건을 만족해야하고 (합이 1이 아니더라도 1을 넘을 순 없어야하니까요), sum(a.prob * b.user_prob)에선 1을 넘지 않습니다.
재구현 코드는 다음과 같습니다:
sum(a.prob * b.prob)의 경우:
SELECTSUM(prob_ii) AS summed
FROM (
SELECTgraph_iu.item_indexAS item_index1,
graph_ui.item_indexAS item_index2,
SUM(graph_iu.prob*graph_ui.prob) AS prob_ii
FROM tmp_p3_graph AS graph_iu
INNER JOIN tmp_p3_graph AS graph_ui
ONgraph_iu.user_index=graph_ui.user_indexANDgraph_iu.item_index!=graph_ui.item_indexGROUP BYgraph_iu.item_index,
graph_ui.item_index
) AS multiplied
GROUP BY
item_index1
ORDER BY
summed DESCLIMIT10;
sum(a.prob * b.user_prob)의 경우:
SELECTSUM(prob_ii) AS summed
FROM (
SELECTgraph_iu.item_indexAS item_index1,
graph_ui.item_indexAS item_index2,
SUM(graph_iu.prob*graph_ui.user_prob) AS prob_ii
FROM tmp_p3_graph AS graph_iu
INNER JOIN tmp_p3_graph AS graph_ui
ONgraph_iu.user_index=graph_ui.user_indexANDgraph_iu.item_index!=graph_ui.item_indexGROUP BYgraph_iu.item_index,
graph_ui.item_index
) AS multiplied
GROUP BY
item_index1
ORDER BY
summed DESCLIMIT10;
안녕하세요..
코드를 보다보니 약간 궁금한 부분이 생겼습니다.
commerce의 4.4에서 P3 추천을 하는 부분에서 아래와 같은 코드가 있는데요:
여기서
sum(a.prob * b.prob) as prob
하는 부분이 있는데,a
는 item → user 역할이고b
는 user → item 역할이기 때문에b
에선user_prob
을 가져오는게 맞지 않나요?a
에선 P(user|item)를,b
에선 P(item|user)를 담당해주기 때문이라고 생각했습니다.감사합니다.
The text was updated successfully, but these errors were encountered: