Code Monkey home page Code Monkey logo

Comments (1)

theeluwin avatar theeluwin commented on July 17, 2024

sum(a.prob * b.prob)으로 계산했을 경우, item_index1GROUP BY해서, 즉 row의 합을 구해보면 1을 훌쩍 넘게 됩니다.
지금은 random walk 중이니까 row-stochastic 조건을 만족해야하고 (합이 1이 아니더라도 1을 넘을 순 없어야하니까요), sum(a.prob * b.user_prob)에선 1을 넘지 않습니다.

재구현 코드는 다음과 같습니다:

  1. sum(a.prob * b.prob)의 경우:
SELECT
    SUM(prob_ii) AS summed
FROM (
    SELECT
        graph_iu.item_index AS item_index1,
        graph_ui.item_index AS 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
        ON
            graph_iu.user_index = graph_ui.user_index
            AND graph_iu.item_index != graph_ui.item_index
    GROUP BY
        graph_iu.item_index,
        graph_ui.item_index
) AS multiplied
GROUP BY
    item_index1
ORDER BY
    summed DESC
LIMIT 10;
  1. sum(a.prob * b.user_prob)의 경우:
SELECT
    SUM(prob_ii) AS summed
FROM (
    SELECT
        graph_iu.item_index AS item_index1,
        graph_ui.item_index AS 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
        ON
            graph_iu.user_index = graph_ui.user_index
            AND graph_iu.item_index != graph_ui.item_index
    GROUP BY
        graph_iu.item_index,
        graph_ui.item_index
) AS multiplied
GROUP BY
    item_index1
ORDER BY
    summed DESC
LIMIT 10;

from fc-rec-workshop.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.