You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Alessandro Suglia <al...@yahoo.com> on 2014/05/03 12:11:40 UTC

Mahout recommendation in implicit feedback situation

Good morning,
I've tried to create a recommender system using Mahout in an implicit 
feedback situation. What I'm trying to do is explained exactlly in this 
post on stack overflow: 
http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation. 
<http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation>
As you can see, I'm having some problem with it simply because I cannot 
get the result that I expect (a value between 0 and 1) when I try to 
predict a score for a specific item.

Someone here can help me, please?

Thank you in advance.

Alessandro Suglia

Re: Mahout recommendation in implicit feedback situation

Posted by Sebastian Schelter <ss...@apache.org>.
Alessandro,

which version of Mahout are you using? I had a look at the current 
implementation of GenericBooleanPrefUserBasedRecommender and its
doEstimatePreference method returns the sum of similarities of users 
that have also interacted with the item. So that should be different 
from either 0 or 1.

--sebastian

On 05/03/2014 05:00 PM, Alessandro Suglia wrote:
> Sorry Sebastian, maybe you haven't the possibility to read the post on
> SO, so I'll report the code here.
> I've already used the GenericBooleanPrefUserBasedRecommender in order to
> generate the recommendation and the results are the same.
>
> |     DataModel  trainModel=  new  FileDataModel(new
> File(String.valueOf(Main.class.getResource("/binarized/u1.base").getFile())));
>
>      DataModel  testModel=  new  FileDataModel(new
> File(String.valueOf(Main.class.getResource("/binarized/u1.test").getFile())));
>
>      UserSimilarity  similarity=  new
> TanimotoCoefficientSimilarity(trainModel);
>      UserNeighborhood  neighborhood=  new  NearestNUserNeighborhood(35,
> similarity,  trainModel);
>
>      GenericBooleanPrefUserBasedRecommender  userBased=  new
> GenericBooleanPrefUserBasedRecommender(trainModel,  neighborhood,
> similarity);
>
>      long  firstUser=  testModel.getUserIDs().nextLong();  // get the
> first user
>
>      // try to recommender items for the first user
>      for(LongPrimitiveIterator  iterItem=
> testModel.getItemIDsFromUser(firstUser).iterator();
> iterItem.hasNext();  )  {
>          long  currItem=  iterItem.nextLong();
>          // estimates preference for the current item for the first user
>          System.out.println("Estimated preference for item"  +
> currItem+  " is"  +  userBased.estimatePreference(firstUser,  currItem));
>
>      }
>
> |
>
> Can you explain to me where is the error in this code?
>
> Thank you.
>
> On 05/03/14 16:42, Sebastian Schelter wrote:
>> You should try the
>>
>> org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender
>>
>>
>> which has been built to handle such data.
>>
>> Best,
>> Sebastian
>>
>>
>> On 05/03/2014 04:34 PM, Alessandro Suglia wrote:
>>> I have described it in the SO's post:
>>> "When I execute this code, the result is a list of 0.0 or 1.0 which are
>>> not useful in the context of top-n recommendation in implicit feedback
>>> context. Simply because I have to obtain, for each item, an estimated
>>> rate which stays in the range [0, 1] in order to rank the list in
>>> decreasing order and construct the top-n recommendation appropriately."
>>> On 05/03/14 16:25, Sebastian Schelter wrote:
>>>> Hi Allessandro,
>>>>
>>>> what result do you expect and what do you get? Can you give a concrete
>>>> example?
>>>>
>>>> --sebastian
>>>>
>>>> On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
>>>>> Good morning,
>>>>> I've tried to create a recommender system using Mahout in an implicit
>>>>> feedback situation. What I'm trying to do is explained exactlly in
>>>>> this
>>>>> post on stack overflow:
>>>>> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation.
>>>>>
>>>>>
>>>>> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation>
>>>>>
>>>>>
>>>>>
>>>>> As you can see, I'm having some problem with it simply because I
>>>>> cannot
>>>>> get the result that I expect (a value between 0 and 1) when I try to
>>>>> predict a score for a specific item.
>>>>>
>>>>> Someone here can help me, please?
>>>>>
>>>>> Thank you in advance.
>>>>>
>>>>> Alessandro Suglia
>>>>>
>>>>
>>>
>>
>
>


Re: Mahout recommendation in implicit feedback situation

Posted by Alessandro Suglia <al...@yahoo.com>.
Sorry Sebastian, maybe you haven't the possibility to read the post on 
SO, so I'll report the code here.
I've already used the GenericBooleanPrefUserBasedRecommender in order to 
generate the recommendation and the results are the same.

|     DataModel  trainModel=  new  FileDataModel(new  File(String.valueOf(Main.class.getResource("/binarized/u1.base").getFile())));
     DataModel  testModel=  new  FileDataModel(new  File(String.valueOf(Main.class.getResource("/binarized/u1.test").getFile())));
     UserSimilarity  similarity=  new  TanimotoCoefficientSimilarity(trainModel);
     UserNeighborhood  neighborhood=  new  NearestNUserNeighborhood(35,  similarity,  trainModel);

     GenericBooleanPrefUserBasedRecommender  userBased=  new  GenericBooleanPrefUserBasedRecommender(trainModel,  neighborhood,  similarity);

     long  firstUser=  testModel.getUserIDs().nextLong();  // get the first user

     // try to recommender items for the first user
     for(LongPrimitiveIterator  iterItem=  testModel.getItemIDsFromUser(firstUser).iterator();  iterItem.hasNext();  )  {
         long  currItem=  iterItem.nextLong();
         // estimates preference for the current item for the first user
         System.out.println("Estimated preference for item"  +  currItem+  " is"  +  userBased.estimatePreference(firstUser,  currItem));

     }

|

Can you explain to me where is the error in this code?

Thank you.

On 05/03/14 16:42, Sebastian Schelter wrote:
> You should try the
>
> org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender 
>
>
> which has been built to handle such data.
>
> Best,
> Sebastian
>
>
> On 05/03/2014 04:34 PM, Alessandro Suglia wrote:
>> I have described it in the SO's post:
>> "When I execute this code, the result is a list of 0.0 or 1.0 which are
>> not useful in the context of top-n recommendation in implicit feedback
>> context. Simply because I have to obtain, for each item, an estimated
>> rate which stays in the range [0, 1] in order to rank the list in
>> decreasing order and construct the top-n recommendation appropriately."
>> On 05/03/14 16:25, Sebastian Schelter wrote:
>>> Hi Allessandro,
>>>
>>> what result do you expect and what do you get? Can you give a concrete
>>> example?
>>>
>>> --sebastian
>>>
>>> On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
>>>> Good morning,
>>>> I've tried to create a recommender system using Mahout in an implicit
>>>> feedback situation. What I'm trying to do is explained exactlly in 
>>>> this
>>>> post on stack overflow:
>>>> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation. 
>>>>
>>>>
>>>> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation> 
>>>>
>>>>
>>>>
>>>> As you can see, I'm having some problem with it simply because I 
>>>> cannot
>>>> get the result that I expect (a value between 0 and 1) when I try to
>>>> predict a score for a specific item.
>>>>
>>>> Someone here can help me, please?
>>>>
>>>> Thank you in advance.
>>>>
>>>> Alessandro Suglia
>>>>
>>>
>>
>


Re: Mahout recommendation in implicit feedback situation

Posted by Pat Ferrel <pa...@gmail.com>.
Actually the regular cooccurrence recommender should work too. Your example on Stackoverflow is calling the wrong method to get recs, call .recommend(uersId) to get an ordered list of ids with strengths.

It looks to me like you are getting preference data from the user, which in this case is 1 or 0—not recommendations.

On May 3, 2014, at 7:42 AM, Sebastian Schelter <ss...@apache.org> wrote:

You should try the

org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender

which has been built to handle such data.

Best,
Sebastian


On 05/03/2014 04:34 PM, Alessandro Suglia wrote:
> I have described it in the SO's post:
> "When I execute this code, the result is a list of 0.0 or 1.0 which are
> not useful in the context of top-n recommendation in implicit feedback
> context. Simply because I have to obtain, for each item, an estimated
> rate which stays in the range [0, 1] in order to rank the list in
> decreasing order and construct the top-n recommendation appropriately."
> On 05/03/14 16:25, Sebastian Schelter wrote:
>> Hi Allessandro,
>> 
>> what result do you expect and what do you get? Can you give a concrete
>> example?
>> 
>> --sebastian
>> 
>> On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
>>> Good morning,
>>> I've tried to create a recommender system using Mahout in an implicit
>>> feedback situation. What I'm trying to do is explained exactlly in this
>>> post on stack overflow:
>>> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation.
>>> 
>>> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation>
>>> 
>>> 
>>> As you can see, I'm having some problem with it simply because I cannot
>>> get the result that I expect (a value between 0 and 1) when I try to
>>> predict a score for a specific item.
>>> 
>>> Someone here can help me, please?
>>> 
>>> Thank you in advance.
>>> 
>>> Alessandro Suglia
>>> 
>> 
> 



Re: Mahout recommendation in implicit feedback situation

Posted by Sebastian Schelter <ss...@apache.org>.
You should try the

org.apache.mahout.cf.taste.impl.recommender.GenericBooleanPrefUserBasedRecommender

which has been built to handle such data.

Best,
Sebastian


On 05/03/2014 04:34 PM, Alessandro Suglia wrote:
> I have described it in the SO's post:
> "When I execute this code, the result is a list of 0.0 or 1.0 which are
> not useful in the context of top-n recommendation in implicit feedback
> context. Simply because I have to obtain, for each item, an estimated
> rate which stays in the range [0, 1] in order to rank the list in
> decreasing order and construct the top-n recommendation appropriately."
> On 05/03/14 16:25, Sebastian Schelter wrote:
>> Hi Allessandro,
>>
>> what result do you expect and what do you get? Can you give a concrete
>> example?
>>
>> --sebastian
>>
>> On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
>>> Good morning,
>>> I've tried to create a recommender system using Mahout in an implicit
>>> feedback situation. What I'm trying to do is explained exactlly in this
>>> post on stack overflow:
>>> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation.
>>>
>>> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation>
>>>
>>>
>>> As you can see, I'm having some problem with it simply because I cannot
>>> get the result that I expect (a value between 0 and 1) when I try to
>>> predict a score for a specific item.
>>>
>>> Someone here can help me, please?
>>>
>>> Thank you in advance.
>>>
>>> Alessandro Suglia
>>>
>>
>


Re: Mahout recommendation in implicit feedback situation

Posted by Alessandro Suglia <al...@yahoo.com>.
I have described it in the SO's post:
"When I execute this code, the result is a list of 0.0 or 1.0 which are 
not useful in the context of top-n recommendation in implicit feedback 
context. Simply because I have to obtain, for each item, an estimated 
rate which stays in the range [0, 1] in order to rank the list in 
decreasing order and construct the top-n recommendation appropriately."
On 05/03/14 16:25, Sebastian Schelter wrote:
> Hi Allessandro,
>
> what result do you expect and what do you get? Can you give a concrete 
> example?
>
> --sebastian
>
> On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
>> Good morning,
>> I've tried to create a recommender system using Mahout in an implicit
>> feedback situation. What I'm trying to do is explained exactlly in this
>> post on stack overflow:
>> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation. 
>>
>> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation> 
>>
>>
>> As you can see, I'm having some problem with it simply because I cannot
>> get the result that I expect (a value between 0 and 1) when I try to
>> predict a score for a specific item.
>>
>> Someone here can help me, please?
>>
>> Thank you in advance.
>>
>> Alessandro Suglia
>>
>


Re: Mahout recommendation in implicit feedback situation

Posted by Sebastian Schelter <ss...@apache.org>.
Hi Allessandro,

what result do you expect and what do you get? Can you give a concrete 
example?

--sebastian

On 05/03/2014 12:11 PM, Alessandro Suglia wrote:
> Good morning,
> I've tried to create a recommender system using Mahout in an implicit
> feedback situation. What I'm trying to do is explained exactlly in this
> post on stack overflow:
> http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation.
> <http://stackoverflow.com/questions/23077735/mahout-recommendation-in-implicit-feedback-situation>
>
> As you can see, I'm having some problem with it simply because I cannot
> get the result that I expect (a value between 0 and 1) when I try to
> predict a score for a specific item.
>
> Someone here can help me, please?
>
> Thank you in advance.
>
> Alessandro Suglia
>