Re: How to build a recommender system?
Date: June 03, 2019 01:14PM
I know this thread is dead but I have one other thought if anyone stumbles upon this in the future.
I have applied a very basic recommender using association rules is to take a list of transactions in a database, and a list of rules. Build a Trie out of the rule's ordered antecedent. When the Trie is evaluated it should return the consequent and interest metric for each node at that point in the trie. Then take an ordered transaction and recursively walk down the trie returning all rules that are subsets of that transaction. For instance, if I had rules
rule1 {1,2} -> 7, Interest: 1.4 and
rule2 {1} -> 3, Interest: 1.1
rule3 {1,2,3}->4, Interest: 1.01
rule4 {2} ->6, Interest: 1.9
and a transaction {1,2}
The Trie would look approximately like this
{{{{1:3,1.4},2:7,1.1},3:4,1.01},{2:6,1.9}}
So evaluation of the transaction would be as follows.
Iteration: 1 Item = 1, Recursion Depth:0 (from transaction item 1)
Returns '3, 1.4' (1.1 is the interest metric, 3 is the item number)
Iteration: 1 Item = 2, Recursion Depth: 1
Returns '7, 1.1'
Iteration: 2 Item = 2, Recursion Depth:0
Returns '6, 1.9'
Sort according to the interest metric of choice.
Final Recommendations {6,3,7}
If you also include an interest metric like lift, confidence, conviction, etc. then you can return this as well and rank the returned items like 6>3>7. Obviously, this won't work in all cases but the Trie is fast to evaluate and build. It may suit your needs as a limited form of recommender.
If you have a very small number of transactions and rules then a simple check if a rule is a subset of the transaction should be sufficient. Otherwise, the best case complexity is unfriendly for quick evaluation and a trie will speed this up considerably.