Search code examples
c#aforgeaccord.net

find most frequently used products / items by a specific user


I am developing a web API for an enterprise application. In current scenario, when any user clicks on any drop down control, a request is made to the server, now the ADO.Net code simply fetches the list from the appropriate table in alphabetical order and response is returned as JSON. This is pretty straightforward.

Now, what I want to do is, to return most frequently used items by a specific user in my response. For Example, I have a drop down for all items by a company. Now user A mostly use item 1, item 2, item 3, while user B mostly use item 4, item 5, item 6. Now rather than returning a constant list in alphabetical order each time, I want to return a list to user A in which item 1, item 2, item 3 should be on top while for user B item 4, item 5, item 6 should be on top.

I have searched it and learnt that I can do this type of stuff by machine learning algorithms. I am totally unaware from this domain. I found AFORGE.NET and Accord.NET as some good frameworks for .NET, but I am still unclear about how can I do it?

Please somebody guide me, how can I achieve it?

Best Regards


Solution

  • I believe Saeb is correct. You can modify your DB to have a many-to-many relationship between Users and Products. The Users_And_Products table should store a count for any item that has been viewed:

    UserID ProductID Count
    001    123       1      
    001    010       4
    002    123       5
    002    050       4
    002    051       3
    

    As you can see, you will not need to store a count for Products that have been viewed zero times, but just keep track of the ones that have been viewed at all. This then becomes a trivial SQL query (where UserID='001' orderby Count desc).