3
$\begingroup$

I am given a dataset where there are people profiles and the types of beer each person likes, given in a list. What is the best way to find relevant beers given a specific beer based on this data?

edit: I researched my question more and found that it is in the realm of collaborative filtering.

From my research, the examples that are currently given involve ratings or other metrics, but my dataset is very minimal. It includes the beers bought by a person. Therefore The only data we have is weather or not a person bought a specific beer.

The format is as such:

Person | Beers bought
1         A,B,C,R,G,S
2         A,F,U,I,T
3         B,C
4         J,R

From what I think, it appears to be an implicit item-based collaborative filter. My question, is, given one Beer say A, give the best recommendation of 3 beers.

My current attempt is given 1 beer, find all the users that bought it, then look at all the beers that they bought and find the 3 most common ones. I believe that that is too naive so what other methods are possible? I am thinking of having a weighting function but I am not sure how to go about it.

$\endgroup$
3
$\begingroup$

I would generally consider this an over-broad question, but here's a tutorial specifically on building a beer recommendation engine in R based on a dataset of user reviews from BeerAdvocate.com: http://blog.yhathq.com/posts/recommender-system-in-r.html

$\endgroup$
  • $\begingroup$ I actually looked at that dataset before but that example involved characteristics of the beer such as flavor. My dataset is solely the sets of beers that specific users bought. A lot of examples online involve more complexity, however I have a minimalist dataset. $\endgroup$ – ChairmanMeow Jun 30 '13 at 23:29
  • $\begingroup$ Try a NN approach to collaborative filtering. Consider adding weight to the beers around which users cluster. Building a recommendation system is an art, and your dataset only has one variable. You're going to need to play around with this and see what works best with your data. $\endgroup$ – David Marx Jul 2 '13 at 16:16
1
$\begingroup$

One way is to find beers 'associated' with a given beer A, in the sense: "Users who bought beer A also bought beer X." A similarity measure that directly gives this association is: For a beer X, (Users who bought X and A)/(Users who bought A). Beers which have the highest similarity with A can be recommended to users who bought A.

This is only one possible nearest-neighbour approach, and as @david-marx mentioned, you have to try out a few options on your data.

$\endgroup$
1
$\begingroup$

Here is a quick example of how to use SVD in R for recommendations. First create a 0/1 matrix indicating which person drinks which beer. Next, use SVD to decompose the matrix, and recreate it with the K most significant factors. Next, find the combinations in which the person did not drink the beer - but should have, using the model.

Beers= data.frame(Client=c(1,1,1,1,1,1,2,2,2,2,2,3,3,4,4), 
              Beer=c("A","B","C","R","G","S","A","F","U","I","T","B","C","J","R"),
              idx=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1))

Beers_tbl = dcast(Beers, Client ~ Beer, value.var="idx", fun.aggregate=sum)
rownames(Beers_tbl)=Beers_tbl[,1]
Beers_tbl=Beers_tbl[,-1]

my_svd=svd(Beers_tbl)
K=2
Beers_tbl_pred=my_svd$u[,1:K] %*% diag(my_svd$d[1:K]) %*% t(my_svd$v[,1:K])

Recommend=apply(Beers_tbl_pred-Beers_tbl,2,function(x) {ifelse(x>0.2,1,0)})*(1-Beers_tbl)
$\endgroup$
0
$\begingroup$

Could you build a recommender system with the frequency of purchase as the value? Is it possible to derive frequency of purchase?

You could build an item-based model with user_name, beer_id, frequency_of_purchase (the total count of their purchases). You would take the matrix of users/beers/frequency, call it Matrix A, and the matrix of similarity between beers in Matrix B, and multiply the two matrices to get the resulting recommendation in matrix C. You could also use association rules to determine the probability of someone buying a beer, if they've bought a set of other beers,

beer1, beer2, beer3 --> beer6.

With association rules, you could create a binary matrix that contains all of the users and all of the possible beers with a 0/1 for each of the possible beers, depending on whether a user has purchased a beer or not. There is a fair amount of literature on this on the web, including a decent package in R (arules).

$\endgroup$
0
$\begingroup$

You can build the recommendation system based on binary data of purchase / non-purchase and experiment with different approaches (content - or user -based). Essentially, you start with the matrix / data frame that lists users in rows and products (beer brands) in columns, where 1's indicate purchase and 0's no purchase and you take it from there.

What language are you using? Here are some useful tutorials in R/ Python to start with:

MovieLense Recommendation System in R

Collaborative Filtering with R

Collaborative Filtering with Python

$\endgroup$
0
$\begingroup$

It has been over 4 years since you asked this question and probably you have conquered this problem efficiently. However, being a data mining student currently, I would still love to answer this question.

If your requirement is bound to recommendation engine based on a training data set, you could go for a simpler approach. FP Growth from frequent-pattern tree (FP-tree), will mine frequent data items and make your engine faster and more efficient.

Also, as I mentioned, I am also a student. If there is a better approach than mine, please let me know! :)

$\endgroup$

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 2
    $\begingroup$ Could you make your answer clearer by explaining what you mean by FP Growth? $\endgroup$ – mkt Aug 19 '17 at 18:18
  • $\begingroup$ @mkt Frequent Pattern Growth (FP-Growth) is an algorithm which helps in mining frequent data items. I attached a link in the text which explains the algorithm. You can also read many articles and research on the algorithm from Google. $\endgroup$ – Gaurav Saini Sep 24 '17 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.