How can I implement a recommendation engine?

前端 未结 4 647
礼貌的吻别
礼貌的吻别 2021-01-31 20:15

Please be patient with my writing, as my English is not proficient.

As a programmer, I wanna learn about the algorithm, or the machine learning intelligence, that are im

相关标签:
4条回答
  • 2021-01-31 20:50

    I think, you talk about knowledge base systems. I don't remember the programming language (maybe LISP), but there is implementations. Also, look at OWL.

    0 讨论(0)
  • 2021-01-31 20:51

    A first attempt could look like this:

    //First Calculate how often any product pair was bought together
    //The time/memory should be about Sum over all Customers of Customer.BoughtProducts^2
    Dictionary<Pair<ProductID,ProductID>> boughtTogether=new Dictionary<Pair<ProductID,ProductID>>();
    foreach(Customer in Customers)
    {
        foreach(product1 in Customer.BoughtProducts)
            foreach(product2 in Customer.BoughtProducts)
                {
                    int counter=boughtTogether[Pair(product1,product2)] or 0 if missing;
                    counter++;
                    boughtTogether[Pair(product1,product2)]=counter;
                }
    }
    
    boughtTogether.GroupBy(entry.Key.First).Select(group.OrderByDescending(entry=>entry.Value).Take(10).Select(new{key.Second as ProductID,Value as Count}));
    

    First I calculate how often each pair of products was bought together, and then I group them by the product and select the top 20 other products bought with it. The result should be put into some kind of dictionary keyed by product ID.

    This might get too slow or cost too much memory for large databases.

    0 讨论(0)
  • 2021-01-31 20:52

    There's also prediction.io if you're looking for an open source solution or SaaS solutions like mag3llan.com.

    0 讨论(0)
  • 2021-01-31 21:03

    The are 2 different types of recommendation engines.

    The simplest is item-based ie "customers that bought product A also bought product B". This is easy to implement. Store a sparse symmetrical matrix nxn (where n is the number of items). Each element (m[a][b]) is the number of times anyone has bought item 'a' along with item 'b'.

    The other is user-based. That is "people like you often like things like this". A possible solution to this problem is k-means clustering. ie construct a set of clusters where users of similar taste are placed in the same cluster and make suggestions based on users in the same cluster.

    A better solution, but an even more complicated one is a technique called Restricted Boltzmann Machines. There's an introduction to them here

    0 讨论(0)
提交回复
热议问题