You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by samsam <ya...@gmail.com> on 2010/07/05 14:52:34 UTC

Recommend for anonymous users

Hello,all
I want to build recommendation engine with apache mahout,I have read some
reading material,and I still have some questions.

1)How to recommend for anonymous users
I think recommendation engine  should return recommendations given a item
id.For example,a anonymous user reviews some items,
and tell the recommendation what he reviews,and compute with the reviews
histories.

2)How to compute the items similarity dataset
Without use items similarity dataset,we can make ItemBasedRecommender
with PearsonCorrelationSimilarity,but
we need to make recommendations with extra attributes of items,
so we should use the items similarity dataset,how to build the dataset is
the key point.
-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
Yes, that's the problem. You should not be modifying taste-web at all.
That's not a place for your code. It can't "see" the rest of your
code. Build and package all of your code together, not only part of
it.

On Mon, Jul 12, 2010 at 12:03 PM, samsam <ya...@gmail.com> wrote:
> I think build the recommender and related class into a jar,and put it to the
> taste-web/lib directory, I put the AnonymousRecommenderServlet
> to taste-web/src directory,but in AnonymousRecommenderServlet can't
> import AnonymousRecommender in that jar.I don't know what's the problem?

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
I think build the recommender and related class into a jar,and put it to the
taste-web/lib directory, I put the AnonymousRecommenderServlet
to taste-web/src directory,but in AnonymousRecommenderServlet can't
import AnonymousRecommender
in that jar.I don't know what's the problem?

On Fri, Jul 9, 2010 at 4:32 PM, Sean Owen <sr...@gmail.com> wrote:

> Oh I see. It appears you've added your own code like
> AnonymousRecommenderServlet into the framework code in taste-web/src/.
> This isn't the intent. You want all your code to be built together
> into one .jar file, separately. The module of course doesn't depend on
> your code.
>
> It would also work if you put all your code in taste-web/src/ and
> didn't build any .jar file but that is probably not a good practice.
>
> Sean
>
> On Fri, Jul 9, 2010 at 2:50 AM, samsam <ya...@gmail.com> wrote:
> > I have put my jar file in the lib directory,but I think the class still
> > can't be imported.
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
Oh I see. It appears you've added your own code like
AnonymousRecommenderServlet into the framework code in taste-web/src/.
This isn't the intent. You want all your code to be built together
into one .jar file, separately. The module of course doesn't depend on
your code.

It would also work if you put all your code in taste-web/src/ and
didn't build any .jar file but that is probably not a good practice.

Sean

On Fri, Jul 9, 2010 at 2:50 AM, samsam <ya...@gmail.com> wrote:
> I have put my jar file in the lib directory,but I think the class still
> can't be imported.

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
I have put my jar file in the lib directory,but I think the class still
can't be imported.

On Fri, Jul 9, 2010 at 1:34 AM, Sean Owen <sr...@gmail.com> wrote:

> You need to put the .jar file with your own code in the lib/ directory
> under taste-web. Then the build script will package it into the web
> app it builds.
>
> On Thu, Jul 8, 2010 at 4:37 PM, samsam <ya...@gmail.com> wrote:
> > I implemented a recommender named AnonymousRecommender for anonymous
> users,
> > and in AnonymousRecommender I write a method like this to make
> > recommendations.
> > #-----------
> >
> > public synchronized List<RecommendedItem> recommend(PreferenceArray
> > anonymousUserPrefs, int howMany) throws TasteException {
> >
> > plusAnonymousModel.setTempPrefs(anonymousUserPrefs);
> >
> > List<RecommendedItem> recommendations =
> >
> > recommend(PlusAnonymousUserDataModel.TEMP_USER_ID, howMany, null);
> >
> > plusAnonymousModel.setTempPrefs(null);
> >
> > return recommendations;
> >
> > }
> >
> > #--------------
> >
> > And in servlet I will use this recommender to process request,but I can't
> > import the AnonymousRecommender class to invoke the recommend method I
> > write.
> >
> > When mvn package, I got
> >
> /Users/samsam/Lab/mahout-0.3/taste-web/src/main/java/org/apache/mahout/cf/taste/web/AnonymousRecommenderServlet.java:[36,38]
> > package net.gamestreamer.recommendation does not exist
> >
> > Who knnow how to import the AnonymousRecommender class?
> >
> > Best Regards.
> >
> > On Thu, Jul 8, 2010 at 12:48 AM, samsam <ya...@gmail.com> wrote:
> >>
> >> thanks very much!
> >>
> >> On Thu, Jul 8, 2010 at 12:46 AM, Sean Owen <sr...@gmail.com> wrote:
> >>>
> >>> That's a bit of example code for the book. It is in the source code
> >>> made available with the MEAP book. It should be downloadable -- if
> >>> it's not apparent where it's available I'll ask Manning where it is.
> >>>
> >>> I can send it to you -- see attached. You should get it though the
> >>> mailing list won't I believe. But you should find all the source since
> >>> there are more classes than just this.
> >>>
> >>> Sean
> >>>
> >>> On Wed, Jul 7, 2010 at 5:42 PM, samsam <ya...@gmail.com> wrote:
> >>> > I seen LibimsetiRecomender in book <mahout in action>,but i can't
> find
> >>> > it in
> >>> > mahout docs.What is it?
> >>> >
> >>> > On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:
> >>> >
> >>> >> I become more clear about that,thanks for your help very much.
> >>> >>
> >>> >>
> >>> >> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com>
> wrote:
> >>> >>
> >>> >>> Pre-compute the similarity based on what information? You mention
> >>> >>> that
> >>> >>> you don't want to use Pearson and mention item attributes.
> >>> >>>
> >>> >>> If you are trying to use domain-specific attributes of items, then
> >>> >>> it's up to you to write that logic. If you want to say books have a
> >>> >>> "0.5" similarity when they are within the same genre, and "0.9"
> when
> >>> >>> by the same author, you can just write that logic. That's not part
> of
> >>> >>> the framework.
> >>> >>>
> >>> >>> The hook into the framework comes when you implement ItemSimilarity
> >>> >>> with logic like that. Then just use that ItemSimilarity instead of
> >>> >>> one
> >>> >>> of the given implementations. That's all.
> >>> >>>
> >>> >>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com>
> wrote:
> >>> >>> > About the second question,I have not the similarity,I want to
> know
> >>> >>> > is
> >>> >>> how to
> >>> >>> > pre-compute the item similarity.
> >>> >>> >
> >>> >>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com>
> >>> >>> > wrote:
> >>> >>> >
> >>> >>> >> 1) Good question. One answer is to make these "anonymous" users
> >>> >>> >> real
> >>> >>> >> users in your data model, at least temporarily. That is, they
> need
> >>> >>> >> not
> >>> >>> >> be anonymous to the recommender, even if they're not yet a
> >>> >>> >> registered
> >>> >>> >> user as far as your site is concerned.
> >>> >>> >>
> >>> >>> >> There's a class called PlusAnonymousUserDataModel that helps you
> >>> >>> >> do
> >>> >>> >> this. It wraps a DataModel and lets you quickly add a temporary
> >>> >>> >> user,
> >>> >>> >> recommend, then un-add that user. It may be the easiest thing to
> >>> >>> >> try.
> >>> >>> >>
> >>> >>> >> (BTW the book Mahout in Action covers this in section 5.4, in
> the
> >>> >>> >> current MEAP draft.)
> >>> >>> >>
> >>> >>> >> 2) Not sure I fully understand. You already have some external,
> >>> >>> >> pre-computed notion of item similarity? then just feed that in
> to
> >>> >>> >> GenericItemSimilarity and use it from there.
> >>> >>> >>
> >>> >>> >> Sean
> >>> >>> >>
> >>> >>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com>
> >>> >>> >> wrote:
> >>> >>> >> > Hello,all
> >>> >>> >> > I want to build recommendation engine with apache mahout,I
> have
> >>> >>> >> > read
> >>> >>> some
> >>> >>> >> > reading material,and I still have some questions.
> >>> >>> >> >
> >>> >>> >> > 1)How to recommend for anonymous users
> >>> >>> >> > I think recommendation engine  should return recommendations
> >>> >>> >> > given a
> >>> >>> item
> >>> >>> >> > id.For example,a anonymous user reviews some items,
> >>> >>> >> > and tell the recommendation what he reviews,and compute with
> the
> >>> >>> reviews
> >>> >>> >> > histories.
> >>> >>> >> >
> >>> >>> >> > 2)How to compute the items similarity dataset
> >>> >>> >> > Without use items similarity dataset,we can make
> >>> >>> >> > ItemBasedRecommender
> >>> >>> >> > with PearsonCorrelationSimilarity,but
> >>> >>> >> > we need to make recommendations with extra attributes of
> items,
> >>> >>> >> > so we should use the items similarity dataset,how to build the
> >>> >>> dataset is
> >>> >>> >> > the key point.
> >>> >>> >> > --
> >>> >>> >> > I'm samsam.
> >>> >>> >> >
> >>> >>> >>
> >>> >>> >
> >>> >>> >
> >>> >>> >
> >>> >>> > --
> >>> >>> > I'm samsam.
> >>> >>> >
> >>> >>>
> >>> >>
> >>> >>
> >>> >>
> >>> >> --
> >>> >> I'm samsam.
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > I'm samsam.
> >>> >
> >>
> >>
> >>
> >> --
> >> I'm samsam.
> >
> >
> >
> > --
> > I'm samsam.
> >
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
You need to put the .jar file with your own code in the lib/ directory
under taste-web. Then the build script will package it into the web
app it builds.

On Thu, Jul 8, 2010 at 4:37 PM, samsam <ya...@gmail.com> wrote:
> I implemented a recommender named AnonymousRecommender for anonymous users,
> and in AnonymousRecommender I write a method like this to make
> recommendations.
> #-----------
>
> public synchronized List<RecommendedItem> recommend(PreferenceArray
> anonymousUserPrefs, int howMany) throws TasteException {
>
> plusAnonymousModel.setTempPrefs(anonymousUserPrefs);
>
> List<RecommendedItem> recommendations =
>
> recommend(PlusAnonymousUserDataModel.TEMP_USER_ID, howMany, null);
>
> plusAnonymousModel.setTempPrefs(null);
>
> return recommendations;
>
> }
>
> #--------------
>
> And in servlet I will use this recommender to process request,but I can't
> import the AnonymousRecommender class to invoke the recommend method I
> write.
>
> When mvn package, I got
> /Users/samsam/Lab/mahout-0.3/taste-web/src/main/java/org/apache/mahout/cf/taste/web/AnonymousRecommenderServlet.java:[36,38]
> package net.gamestreamer.recommendation does not exist
>
> Who knnow how to import the AnonymousRecommender class?
>
> Best Regards.
>
> On Thu, Jul 8, 2010 at 12:48 AM, samsam <ya...@gmail.com> wrote:
>>
>> thanks very much!
>>
>> On Thu, Jul 8, 2010 at 12:46 AM, Sean Owen <sr...@gmail.com> wrote:
>>>
>>> That's a bit of example code for the book. It is in the source code
>>> made available with the MEAP book. It should be downloadable -- if
>>> it's not apparent where it's available I'll ask Manning where it is.
>>>
>>> I can send it to you -- see attached. You should get it though the
>>> mailing list won't I believe. But you should find all the source since
>>> there are more classes than just this.
>>>
>>> Sean
>>>
>>> On Wed, Jul 7, 2010 at 5:42 PM, samsam <ya...@gmail.com> wrote:
>>> > I seen LibimsetiRecomender in book <mahout in action>,but i can't find
>>> > it in
>>> > mahout docs.What is it?
>>> >
>>> > On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:
>>> >
>>> >> I become more clear about that,thanks for your help very much.
>>> >>
>>> >>
>>> >> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>>> >>
>>> >>> Pre-compute the similarity based on what information? You mention
>>> >>> that
>>> >>> you don't want to use Pearson and mention item attributes.
>>> >>>
>>> >>> If you are trying to use domain-specific attributes of items, then
>>> >>> it's up to you to write that logic. If you want to say books have a
>>> >>> "0.5" similarity when they are within the same genre, and "0.9" when
>>> >>> by the same author, you can just write that logic. That's not part of
>>> >>> the framework.
>>> >>>
>>> >>> The hook into the framework comes when you implement ItemSimilarity
>>> >>> with logic like that. Then just use that ItemSimilarity instead of
>>> >>> one
>>> >>> of the given implementations. That's all.
>>> >>>
>>> >>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>> >>> > About the second question,I have not the similarity,I want to know
>>> >>> > is
>>> >>> how to
>>> >>> > pre-compute the item similarity.
>>> >>> >
>>> >>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com>
>>> >>> > wrote:
>>> >>> >
>>> >>> >> 1) Good question. One answer is to make these "anonymous" users
>>> >>> >> real
>>> >>> >> users in your data model, at least temporarily. That is, they need
>>> >>> >> not
>>> >>> >> be anonymous to the recommender, even if they're not yet a
>>> >>> >> registered
>>> >>> >> user as far as your site is concerned.
>>> >>> >>
>>> >>> >> There's a class called PlusAnonymousUserDataModel that helps you
>>> >>> >> do
>>> >>> >> this. It wraps a DataModel and lets you quickly add a temporary
>>> >>> >> user,
>>> >>> >> recommend, then un-add that user. It may be the easiest thing to
>>> >>> >> try.
>>> >>> >>
>>> >>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>>> >>> >> current MEAP draft.)
>>> >>> >>
>>> >>> >> 2) Not sure I fully understand. You already have some external,
>>> >>> >> pre-computed notion of item similarity? then just feed that in to
>>> >>> >> GenericItemSimilarity and use it from there.
>>> >>> >>
>>> >>> >> Sean
>>> >>> >>
>>> >>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com>
>>> >>> >> wrote:
>>> >>> >> > Hello,all
>>> >>> >> > I want to build recommendation engine with apache mahout,I have
>>> >>> >> > read
>>> >>> some
>>> >>> >> > reading material,and I still have some questions.
>>> >>> >> >
>>> >>> >> > 1)How to recommend for anonymous users
>>> >>> >> > I think recommendation engine  should return recommendations
>>> >>> >> > given a
>>> >>> item
>>> >>> >> > id.For example,a anonymous user reviews some items,
>>> >>> >> > and tell the recommendation what he reviews,and compute with the
>>> >>> reviews
>>> >>> >> > histories.
>>> >>> >> >
>>> >>> >> > 2)How to compute the items similarity dataset
>>> >>> >> > Without use items similarity dataset,we can make
>>> >>> >> > ItemBasedRecommender
>>> >>> >> > with PearsonCorrelationSimilarity,but
>>> >>> >> > we need to make recommendations with extra attributes of items,
>>> >>> >> > so we should use the items similarity dataset,how to build the
>>> >>> dataset is
>>> >>> >> > the key point.
>>> >>> >> > --
>>> >>> >> > I'm samsam.
>>> >>> >> >
>>> >>> >>
>>> >>> >
>>> >>> >
>>> >>> >
>>> >>> > --
>>> >>> > I'm samsam.
>>> >>> >
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> I'm samsam.
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > I'm samsam.
>>> >
>>
>>
>>
>> --
>> I'm samsam.
>
>
>
> --
> I'm samsam.
>

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
I implemented a recommender named AnonymousRecommender for anonymous users,
and in AnonymousRecommender I write a method like this to make
recommendations.
#-----------

public synchronized List<RecommendedItem> recommend(PreferenceArray
anonymousUserPrefs, int howMany) throws TasteException {

 plusAnonymousModel.setTempPrefs(anonymousUserPrefs);

 List<RecommendedItem> recommendations =

 recommend(PlusAnonymousUserDataModel.TEMP_USER_ID, howMany, null);

 plusAnonymousModel.setTempPrefs(null);

 return recommendations;

}

#--------------

And in servlet I will use this recommender to process request,but I can't
import the AnonymousRecommender class to invoke the recommend method I
write.

When mvn package, I got
/Users/samsam/Lab/mahout-0.3/taste-web/src/main/java/org/apache/mahout/cf/taste/web/AnonymousRecommenderServlet.java:[36,38]
package net.gamestreamer.recommendation does not exist


Who knnow how to import the AnonymousRecommender class?

Best Regards.

On Thu, Jul 8, 2010 at 12:48 AM, samsam <ya...@gmail.com> wrote:

> thanks very much!
>
>
> On Thu, Jul 8, 2010 at 12:46 AM, Sean Owen <sr...@gmail.com> wrote:
>
>> That's a bit of example code for the book. It is in the source code
>> made available with the MEAP book. It should be downloadable -- if
>> it's not apparent where it's available I'll ask Manning where it is.
>>
>> I can send it to you -- see attached. You should get it though the
>> mailing list won't I believe. But you should find all the source since
>> there are more classes than just this.
>>
>> Sean
>>
>> On Wed, Jul 7, 2010 at 5:42 PM, samsam <ya...@gmail.com> wrote:
>> > I seen LibimsetiRecomender in book <mahout in action>,but i can't find
>> it in
>> > mahout docs.What is it?
>> >
>> > On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:
>> >
>> >> I become more clear about that,thanks for your help very much.
>> >>
>> >>
>> >> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>> >>
>> >>> Pre-compute the similarity based on what information? You mention that
>> >>> you don't want to use Pearson and mention item attributes.
>> >>>
>> >>> If you are trying to use domain-specific attributes of items, then
>> >>> it's up to you to write that logic. If you want to say books have a
>> >>> "0.5" similarity when they are within the same genre, and "0.9" when
>> >>> by the same author, you can just write that logic. That's not part of
>> >>> the framework.
>> >>>
>> >>> The hook into the framework comes when you implement ItemSimilarity
>> >>> with logic like that. Then just use that ItemSimilarity instead of one
>> >>> of the given implementations. That's all.
>> >>>
>> >>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>> >>> > About the second question,I have not the similarity,I want to know
>> is
>> >>> how to
>> >>> > pre-compute the item similarity.
>> >>> >
>> >>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com>
>> wrote:
>> >>> >
>> >>> >> 1) Good question. One answer is to make these "anonymous" users
>> real
>> >>> >> users in your data model, at least temporarily. That is, they need
>> not
>> >>> >> be anonymous to the recommender, even if they're not yet a
>> registered
>> >>> >> user as far as your site is concerned.
>> >>> >>
>> >>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>> >>> >> this. It wraps a DataModel and lets you quickly add a temporary
>> user,
>> >>> >> recommend, then un-add that user. It may be the easiest thing to
>> try.
>> >>> >>
>> >>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>> >>> >> current MEAP draft.)
>> >>> >>
>> >>> >> 2) Not sure I fully understand. You already have some external,
>> >>> >> pre-computed notion of item similarity? then just feed that in to
>> >>> >> GenericItemSimilarity and use it from there.
>> >>> >>
>> >>> >> Sean
>> >>> >>
>> >>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com>
>> wrote:
>> >>> >> > Hello,all
>> >>> >> > I want to build recommendation engine with apache mahout,I have
>> read
>> >>> some
>> >>> >> > reading material,and I still have some questions.
>> >>> >> >
>> >>> >> > 1)How to recommend for anonymous users
>> >>> >> > I think recommendation engine  should return recommendations
>> given a
>> >>> item
>> >>> >> > id.For example,a anonymous user reviews some items,
>> >>> >> > and tell the recommendation what he reviews,and compute with the
>> >>> reviews
>> >>> >> > histories.
>> >>> >> >
>> >>> >> > 2)How to compute the items similarity dataset
>> >>> >> > Without use items similarity dataset,we can make
>> ItemBasedRecommender
>> >>> >> > with PearsonCorrelationSimilarity,but
>> >>> >> > we need to make recommendations with extra attributes of items,
>> >>> >> > so we should use the items similarity dataset,how to build the
>> >>> dataset is
>> >>> >> > the key point.
>> >>> >> > --
>> >>> >> > I'm samsam.
>> >>> >> >
>> >>> >>
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > I'm samsam.
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> I'm samsam.
>> >>
>> >
>> >
>> >
>> > --
>> > I'm samsam.
>> >
>>
>
>
>
> --
> I'm samsam.
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
thanks very much!

On Thu, Jul 8, 2010 at 12:46 AM, Sean Owen <sr...@gmail.com> wrote:

> That's a bit of example code for the book. It is in the source code
> made available with the MEAP book. It should be downloadable -- if
> it's not apparent where it's available I'll ask Manning where it is.
>
> I can send it to you -- see attached. You should get it though the
> mailing list won't I believe. But you should find all the source since
> there are more classes than just this.
>
> Sean
>
> On Wed, Jul 7, 2010 at 5:42 PM, samsam <ya...@gmail.com> wrote:
> > I seen LibimsetiRecomender in book <mahout in action>,but i can't find it
> in
> > mahout docs.What is it?
> >
> > On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:
> >
> >> I become more clear about that,thanks for your help very much.
> >>
> >>
> >> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
> >>
> >>> Pre-compute the similarity based on what information? You mention that
> >>> you don't want to use Pearson and mention item attributes.
> >>>
> >>> If you are trying to use domain-specific attributes of items, then
> >>> it's up to you to write that logic. If you want to say books have a
> >>> "0.5" similarity when they are within the same genre, and "0.9" when
> >>> by the same author, you can just write that logic. That's not part of
> >>> the framework.
> >>>
> >>> The hook into the framework comes when you implement ItemSimilarity
> >>> with logic like that. Then just use that ItemSimilarity instead of one
> >>> of the given implementations. That's all.
> >>>
> >>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
> >>> > About the second question,I have not the similarity,I want to know is
> >>> how to
> >>> > pre-compute the item similarity.
> >>> >
> >>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
> >>> >
> >>> >> 1) Good question. One answer is to make these "anonymous" users real
> >>> >> users in your data model, at least temporarily. That is, they need
> not
> >>> >> be anonymous to the recommender, even if they're not yet a
> registered
> >>> >> user as far as your site is concerned.
> >>> >>
> >>> >> There's a class called PlusAnonymousUserDataModel that helps you do
> >>> >> this. It wraps a DataModel and lets you quickly add a temporary
> user,
> >>> >> recommend, then un-add that user. It may be the easiest thing to
> try.
> >>> >>
> >>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
> >>> >> current MEAP draft.)
> >>> >>
> >>> >> 2) Not sure I fully understand. You already have some external,
> >>> >> pre-computed notion of item similarity? then just feed that in to
> >>> >> GenericItemSimilarity and use it from there.
> >>> >>
> >>> >> Sean
> >>> >>
> >>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
> >>> >> > Hello,all
> >>> >> > I want to build recommendation engine with apache mahout,I have
> read
> >>> some
> >>> >> > reading material,and I still have some questions.
> >>> >> >
> >>> >> > 1)How to recommend for anonymous users
> >>> >> > I think recommendation engine  should return recommendations given
> a
> >>> item
> >>> >> > id.For example,a anonymous user reviews some items,
> >>> >> > and tell the recommendation what he reviews,and compute with the
> >>> reviews
> >>> >> > histories.
> >>> >> >
> >>> >> > 2)How to compute the items similarity dataset
> >>> >> > Without use items similarity dataset,we can make
> ItemBasedRecommender
> >>> >> > with PearsonCorrelationSimilarity,but
> >>> >> > we need to make recommendations with extra attributes of items,
> >>> >> > so we should use the items similarity dataset,how to build the
> >>> dataset is
> >>> >> > the key point.
> >>> >> > --
> >>> >> > I'm samsam.
> >>> >> >
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > I'm samsam.
> >>> >
> >>>
> >>
> >>
> >>
> >> --
> >> I'm samsam.
> >>
> >
> >
> >
> > --
> > I'm samsam.
> >
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
That's a bit of example code for the book. It is in the source code
made available with the MEAP book. It should be downloadable -- if
it's not apparent where it's available I'll ask Manning where it is.

I can send it to you -- see attached. You should get it though the
mailing list won't I believe. But you should find all the source since
there are more classes than just this.

Sean

On Wed, Jul 7, 2010 at 5:42 PM, samsam <ya...@gmail.com> wrote:
> I seen LibimsetiRecomender in book <mahout in action>,but i can't find it in
> mahout docs.What is it?
>
> On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:
>
>> I become more clear about that,thanks for your help very much.
>>
>>
>> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>>
>>> Pre-compute the similarity based on what information? You mention that
>>> you don't want to use Pearson and mention item attributes.
>>>
>>> If you are trying to use domain-specific attributes of items, then
>>> it's up to you to write that logic. If you want to say books have a
>>> "0.5" similarity when they are within the same genre, and "0.9" when
>>> by the same author, you can just write that logic. That's not part of
>>> the framework.
>>>
>>> The hook into the framework comes when you implement ItemSimilarity
>>> with logic like that. Then just use that ItemSimilarity instead of one
>>> of the given implementations. That's all.
>>>
>>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>> > About the second question,I have not the similarity,I want to know is
>>> how to
>>> > pre-compute the item similarity.
>>> >
>>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>>> >
>>> >> 1) Good question. One answer is to make these "anonymous" users real
>>> >> users in your data model, at least temporarily. That is, they need not
>>> >> be anonymous to the recommender, even if they're not yet a registered
>>> >> user as far as your site is concerned.
>>> >>
>>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>>> >> recommend, then un-add that user. It may be the easiest thing to try.
>>> >>
>>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>>> >> current MEAP draft.)
>>> >>
>>> >> 2) Not sure I fully understand. You already have some external,
>>> >> pre-computed notion of item similarity? then just feed that in to
>>> >> GenericItemSimilarity and use it from there.
>>> >>
>>> >> Sean
>>> >>
>>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>>> >> > Hello,all
>>> >> > I want to build recommendation engine with apache mahout,I have read
>>> some
>>> >> > reading material,and I still have some questions.
>>> >> >
>>> >> > 1)How to recommend for anonymous users
>>> >> > I think recommendation engine  should return recommendations given a
>>> item
>>> >> > id.For example,a anonymous user reviews some items,
>>> >> > and tell the recommendation what he reviews,and compute with the
>>> reviews
>>> >> > histories.
>>> >> >
>>> >> > 2)How to compute the items similarity dataset
>>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>>> >> > with PearsonCorrelationSimilarity,but
>>> >> > we need to make recommendations with extra attributes of items,
>>> >> > so we should use the items similarity dataset,how to build the
>>> dataset is
>>> >> > the key point.
>>> >> > --
>>> >> > I'm samsam.
>>> >> >
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > I'm samsam.
>>> >
>>>
>>
>>
>>
>> --
>> I'm samsam.
>>
>
>
>
> --
> I'm samsam.
>

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
I seen LibimsetiRecomender in book <mahout in action>,but i can't find it in
mahout docs.What is it?

On Tue, Jul 6, 2010 at 12:07 AM, samsam <ya...@gmail.com> wrote:

> I become more clear about that,thanks for your help very much.
>
>
> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>
>> Pre-compute the similarity based on what information? You mention that
>> you don't want to use Pearson and mention item attributes.
>>
>> If you are trying to use domain-specific attributes of items, then
>> it's up to you to write that logic. If you want to say books have a
>> "0.5" similarity when they are within the same genre, and "0.9" when
>> by the same author, you can just write that logic. That's not part of
>> the framework.
>>
>> The hook into the framework comes when you implement ItemSimilarity
>> with logic like that. Then just use that ItemSimilarity instead of one
>> of the given implementations. That's all.
>>
>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>> > About the second question,I have not the similarity,I want to know is
>> how to
>> > pre-compute the item similarity.
>> >
>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>> >
>> >> 1) Good question. One answer is to make these "anonymous" users real
>> >> users in your data model, at least temporarily. That is, they need not
>> >> be anonymous to the recommender, even if they're not yet a registered
>> >> user as far as your site is concerned.
>> >>
>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>> >> recommend, then un-add that user. It may be the easiest thing to try.
>> >>
>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>> >> current MEAP draft.)
>> >>
>> >> 2) Not sure I fully understand. You already have some external,
>> >> pre-computed notion of item similarity? then just feed that in to
>> >> GenericItemSimilarity and use it from there.
>> >>
>> >> Sean
>> >>
>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>> >> > Hello,all
>> >> > I want to build recommendation engine with apache mahout,I have read
>> some
>> >> > reading material,and I still have some questions.
>> >> >
>> >> > 1)How to recommend for anonymous users
>> >> > I think recommendation engine  should return recommendations given a
>> item
>> >> > id.For example,a anonymous user reviews some items,
>> >> > and tell the recommendation what he reviews,and compute with the
>> reviews
>> >> > histories.
>> >> >
>> >> > 2)How to compute the items similarity dataset
>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>> >> > with PearsonCorrelationSimilarity,but
>> >> > we need to make recommendations with extra attributes of items,
>> >> > so we should use the items similarity dataset,how to build the
>> dataset is
>> >> > the key point.
>> >> > --
>> >> > I'm samsam.
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > I'm samsam.
>> >
>>
>
>
>
> --
> I'm samsam.
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
I become more clear about that,thanks for your help very much.

On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:

> Pre-compute the similarity based on what information? You mention that
> you don't want to use Pearson and mention item attributes.
>
> If you are trying to use domain-specific attributes of items, then
> it's up to you to write that logic. If you want to say books have a
> "0.5" similarity when they are within the same genre, and "0.9" when
> by the same author, you can just write that logic. That's not part of
> the framework.
>
> The hook into the framework comes when you implement ItemSimilarity
> with logic like that. Then just use that ItemSimilarity instead of one
> of the given implementations. That's all.
>
> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
> > About the second question,I have not the similarity,I want to know is how
> to
> > pre-compute the item similarity.
> >
> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
> >
> >> 1) Good question. One answer is to make these "anonymous" users real
> >> users in your data model, at least temporarily. That is, they need not
> >> be anonymous to the recommender, even if they're not yet a registered
> >> user as far as your site is concerned.
> >>
> >> There's a class called PlusAnonymousUserDataModel that helps you do
> >> this. It wraps a DataModel and lets you quickly add a temporary user,
> >> recommend, then un-add that user. It may be the easiest thing to try.
> >>
> >> (BTW the book Mahout in Action covers this in section 5.4, in the
> >> current MEAP draft.)
> >>
> >> 2) Not sure I fully understand. You already have some external,
> >> pre-computed notion of item similarity? then just feed that in to
> >> GenericItemSimilarity and use it from there.
> >>
> >> Sean
> >>
> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
> >> > Hello,all
> >> > I want to build recommendation engine with apache mahout,I have read
> some
> >> > reading material,and I still have some questions.
> >> >
> >> > 1)How to recommend for anonymous users
> >> > I think recommendation engine  should return recommendations given a
> item
> >> > id.For example,a anonymous user reviews some items,
> >> > and tell the recommendation what he reviews,and compute with the
> reviews
> >> > histories.
> >> >
> >> > 2)How to compute the items similarity dataset
> >> > Without use items similarity dataset,we can make ItemBasedRecommender
> >> > with PearsonCorrelationSimilarity,but
> >> > we need to make recommendations with extra attributes of items,
> >> > so we should use the items similarity dataset,how to build the dataset
> is
> >> > the key point.
> >> > --
> >> > I'm samsam.
> >> >
> >>
> >
> >
> >
> > --
> > I'm samsam.
> >
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
You would want to download the latest source code from Subversion and
build it locally.
https://cwiki.apache.org/confluence/display/MAHOUT/Version+Control

On Thu, Jul 15, 2010 at 11:37 AM, samsam <ya...@gmail.com> wrote:
> where can I get the latest jar of mahout?
>
> On Thu, Jul 15, 2010 at 6:16 PM, Sean Owen <sr...@gmail.com> wrote:
>
>> I committed a possible fix.
>>
>> On Thu, Jul 15, 2010 at 8:57 AM, Sean Owen <sr...@gmail.com> wrote:
>> > I believe I see the issue. The temporary anonymous user has
>> > preferences for items that don't otherwise exist in the data model.
>> > And the particular data model delegate doesn't like that. It should be
>> > fairly simple to deal with; I just need a moment to think through how
>> > that should look.
>>
>
>
>
> --
> I'm samsam.
>

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
where can I get the latest jar of mahout?

On Thu, Jul 15, 2010 at 6:16 PM, Sean Owen <sr...@gmail.com> wrote:

> I committed a possible fix.
>
> On Thu, Jul 15, 2010 at 8:57 AM, Sean Owen <sr...@gmail.com> wrote:
> > I believe I see the issue. The temporary anonymous user has
> > preferences for items that don't otherwise exist in the data model.
> > And the particular data model delegate doesn't like that. It should be
> > fairly simple to deal with; I just need a moment to think through how
> > that should look.
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
I committed a possible fix.

On Thu, Jul 15, 2010 at 8:57 AM, Sean Owen <sr...@gmail.com> wrote:
> I believe I see the issue. The temporary anonymous user has
> preferences for items that don't otherwise exist in the data model.
> And the particular data model delegate doesn't like that. It should be
> fairly simple to deal with; I just need a moment to think through how
> that should look.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
I believe I see the issue. The temporary anonymous user has
preferences for items that don't otherwise exist in the data model.
And the particular data model delegate doesn't like that. It should be
fairly simple to deal with; I just need a moment to think through how
that should look.

Sean

On Thu, Jul 15, 2010 at 8:50 AM, Sebastian Schelter
<ss...@googlemail.com> wrote:
> Hi Sansam,
>
> Are you using the code from the current trunk? And can you reproduce
> this error? If yes, file a bug ticket and I'll try to fix it.
>

Re: Recommend for anonymous users

Posted by Sebastian Schelter <ss...@googlemail.com>.
Hi Sansam,

Are you using the code from the current trunk? And can you reproduce
this error? If yes, file a bug ticket and I'll try to fix it.

--sebastian

Am 15.07.2010 08:55, schrieb samsam:
> sometimes,I get this error
> ----------------------------------
>
> java.lang.IllegalArgumentException: size is less than 1
> 	org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray.<init>(GenericItemPreferenceArray.java:49)
> 	org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray.<init>(GenericItemPreferenceArray.java:56)
> 	org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel.getPreferencesForItem(AbstractJDBCDataModel.java:441)
> 	org.apache.mahout.cf.taste.impl.model.PlusAnonymousUserDataModel.getPreferencesForItem(PlusAnonymousUserDataModel.java:124)
> 	org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender.getAllOtherItems(AbstractRecommender.java:107)
> 	org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender.recommend(GenericItemBasedRecommender.java:98)
> 	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:66)
> 	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:39)
> 	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:52)
> 	net.gamestreamer.recommendation.servlet.AnonymousRecommenderServlet.doGet(AnonymousRecommenderServlet.java:97)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>
> ----------------------
>
> I don't know what's the problem.
>
>
> On Thu, Jul 15, 2010 at 4:20 AM, Sean Owen <sr...@gmail.com> wrote:
>
>   
>> Are you giving it enough memory? I wonder whether you are nearly
>> running out of heap and this is making it very very slow.
>>
>> Just give it a bunch of heap with "-Xmx2048m" or something like that.
>>
>> (I'd also recommend Java 6 but that's not the issue here.)
>>
>> On Wed, Jul 14, 2010 at 9:18 PM, Sean Owen <sr...@gmail.com> wrote:
>>     
>>> That's strange, since I've run the same data set and never seen
>>> behavior like this. Yes I run on my laptop too, which is fairly
>>> similar.
>>>
>>> Yes of course the time is consumed somewhere from recommend(), but
>>> where? I think you'd want to get some clue about where within this
>>> processing the time is being consumed.
>>>
>>> 2010/7/14 Young <wo...@126.com>:
>>>       
>>>> I tried the 10M dataset from grouplen. Is it the reason I do the project
>>>>         
>> in my own laptop? It is Intel 2 core 2.4 GB, and RAM 3GB, and Win7 OS.
>>     
>>>> And blow is profiled code.
>>>> -----------------------------------------------------
>>>> //Precompute the model, itemSimilarity.
>>>> DataModel model = new GroupLensDataModel(new File("ratings.dat"));
>>>> ItemSimilarity itemSimilarity = null;
>>>>  try {
>>>>   itemSimilarity = new PearsonCorrelationSimilarity(model);
>>>>  } catch (TasteException e) {
>>>>   e.printStackTrace();
>>>>  }
>>>> Recommender recommender = new
>>>>         
>> GenericItemBasedRecommender(model,itemSimilarity);
>>     
>>>> -----------------------------------------
>>>>
>>>> //Below method consume more than 1min to generate result.
>>>>     itembased_items = recommender.recommend(user_id, 10);
>>>> --------------------------------------------------
>>>> Should I try slope-one?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>       
>>     
>
>
>   


Re: Re: Re: Re: Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
sometimes,I get this error
----------------------------------

java.lang.IllegalArgumentException: size is less than 1
	org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray.<init>(GenericItemPreferenceArray.java:49)
	org.apache.mahout.cf.taste.impl.model.GenericItemPreferenceArray.<init>(GenericItemPreferenceArray.java:56)
	org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel.getPreferencesForItem(AbstractJDBCDataModel.java:441)
	org.apache.mahout.cf.taste.impl.model.PlusAnonymousUserDataModel.getPreferencesForItem(PlusAnonymousUserDataModel.java:124)
	org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender.getAllOtherItems(AbstractRecommender.java:107)
	org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender.recommend(GenericItemBasedRecommender.java:98)
	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:66)
	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:39)
	net.gamestreamer.recommendation.AnonymousRecommender.recommend(AnonymousRecommender.java:52)
	net.gamestreamer.recommendation.servlet.AnonymousRecommenderServlet.doGet(AnonymousRecommenderServlet.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

----------------------

I don't know what's the problem.


On Thu, Jul 15, 2010 at 4:20 AM, Sean Owen <sr...@gmail.com> wrote:

> Are you giving it enough memory? I wonder whether you are nearly
> running out of heap and this is making it very very slow.
>
> Just give it a bunch of heap with "-Xmx2048m" or something like that.
>
> (I'd also recommend Java 6 but that's not the issue here.)
>
> On Wed, Jul 14, 2010 at 9:18 PM, Sean Owen <sr...@gmail.com> wrote:
> > That's strange, since I've run the same data set and never seen
> > behavior like this. Yes I run on my laptop too, which is fairly
> > similar.
> >
> > Yes of course the time is consumed somewhere from recommend(), but
> > where? I think you'd want to get some clue about where within this
> > processing the time is being consumed.
> >
> > 2010/7/14 Young <wo...@126.com>:
> >> I tried the 10M dataset from grouplen. Is it the reason I do the project
> in my own laptop? It is Intel 2 core 2.4 GB, and RAM 3GB, and Win7 OS.
> >> And blow is profiled code.
> >> -----------------------------------------------------
> >> //Precompute the model, itemSimilarity.
> >> DataModel model = new GroupLensDataModel(new File("ratings.dat"));
> >> ItemSimilarity itemSimilarity = null;
> >>  try {
> >>   itemSimilarity = new PearsonCorrelationSimilarity(model);
> >>  } catch (TasteException e) {
> >>   e.printStackTrace();
> >>  }
> >> Recommender recommender = new
> GenericItemBasedRecommender(model,itemSimilarity);
> >> -----------------------------------------
> >>
> >> //Below method consume more than 1min to generate result.
> >>     itembased_items = recommender.recommend(user_id, 10);
> >> --------------------------------------------------
> >> Should I try slope-one?
> >>
> >>
> >>
> >>
> >>
> >
>



-- 
I'm samsam.

Re: Re: Re: Re: Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
Are you giving it enough memory? I wonder whether you are nearly
running out of heap and this is making it very very slow.

Just give it a bunch of heap with "-Xmx2048m" or something like that.

(I'd also recommend Java 6 but that's not the issue here.)

On Wed, Jul 14, 2010 at 9:18 PM, Sean Owen <sr...@gmail.com> wrote:
> That's strange, since I've run the same data set and never seen
> behavior like this. Yes I run on my laptop too, which is fairly
> similar.
>
> Yes of course the time is consumed somewhere from recommend(), but
> where? I think you'd want to get some clue about where within this
> processing the time is being consumed.
>
> 2010/7/14 Young <wo...@126.com>:
>> I tried the 10M dataset from grouplen. Is it the reason I do the project in my own laptop? It is Intel 2 core 2.4 GB, and RAM 3GB, and Win7 OS.
>> And blow is profiled code.
>> -----------------------------------------------------
>> //Precompute the model, itemSimilarity.
>> DataModel model = new GroupLensDataModel(new File("ratings.dat"));
>> ItemSimilarity itemSimilarity = null;
>>  try {
>>   itemSimilarity = new PearsonCorrelationSimilarity(model);
>>  } catch (TasteException e) {
>>   e.printStackTrace();
>>  }
>> Recommender recommender = new GenericItemBasedRecommender(model,itemSimilarity);
>> -----------------------------------------
>>
>> //Below method consume more than 1min to generate result.
>>     itembased_items = recommender.recommend(user_id, 10);
>> --------------------------------------------------
>> Should I try slope-one?
>>
>>
>>
>>
>>
>

Re: Re: Re: Re: Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
That's strange, since I've run the same data set and never seen
behavior like this. Yes I run on my laptop too, which is fairly
similar.

Yes of course the time is consumed somewhere from recommend(), but
where? I think you'd want to get some clue about where within this
processing the time is being consumed.

2010/7/14 Young <wo...@126.com>:
> I tried the 10M dataset from grouplen. Is it the reason I do the project in my own laptop? It is Intel 2 core 2.4 GB, and RAM 3GB, and Win7 OS.
> And blow is profiled code.
> -----------------------------------------------------
> //Precompute the model, itemSimilarity.
> DataModel model = new GroupLensDataModel(new File("ratings.dat"));
> ItemSimilarity itemSimilarity = null;
>  try {
>   itemSimilarity = new PearsonCorrelationSimilarity(model);
>  } catch (TasteException e) {
>   e.printStackTrace();
>  }
> Recommender recommender = new GenericItemBasedRecommender(model,itemSimilarity);
> -----------------------------------------
>
> //Below method consume more than 1min to generate result.
>     itembased_items = recommender.recommend(user_id, 10);
> --------------------------------------------------
> Should I try slope-one?
>
>
>
>
>

Re:Re: Re: Re: Re: Recommend for anonymous users

Posted by Young <wo...@126.com>.
I tried the 10M dataset from grouplen. Is it the reason I do the project in my own laptop? It is Intel 2 core 2.4 GB, and RAM 3GB, and Win7 OS. 
And blow is profiled code.
-----------------------------------------------------
//Precompute the model, itemSimilarity.  
DataModel model = new GroupLensDataModel(new File("ratings.dat"));
ItemSimilarity itemSimilarity = null;
  try {
   itemSimilarity = new PearsonCorrelationSimilarity(model);
  } catch (TasteException e) {
   e.printStackTrace();
  }  
Recommender recommender = new GenericItemBasedRecommender(model,itemSimilarity);
-----------------------------------------

//Below method consume more than 1min to generate result.
     itembased_items = recommender.recommend(user_id, 10);
--------------------------------------------------
Should I try slope-one?





Re: Re: Re: Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
How many unique items?

That result really doesn't look right to me. I don't have a good guess
looking purely at the code. I think you would have to profile it, and
figure out where it is spending so much time. With that more
information maybe we can figure it out.

Sean

2010/7/14 Young <wo...@126.com>:
> Hi Sean,
> Thank you for your reply.
> My items are 100k and users are 100k and each users are expected have 200 ratings and total ratings are 20 million.
> Here is the time.
> Constructing datamodel using time:150968
> Calculating the similarity using time:5
> Constructing recommender using time: 5
> Please enter user_id
> 9
> Time Used:620ms
> Please enter user_id
> 2
> Time Used:369367ms
>
> So based on this situation, what should I do next?
>
>
>
>
>
>
>>That looks basically sound. You probably want to wrap the
>>PearsonCorrelationSimilarity in a CachingItemSimilarity.
>>
>>You may also simply wish to try a different algorithm. What's the data
>>like? if it has lots of items, this is not the best choice.
>>
>>Next step here would be to profile to see where the time is spent. You
>>might just debug, and pause the processing periodically to see where
>>the thread is. That may show where time is spent.
>>
>>2010/7/14 Young <wo...@126.com>:
>>> Thanks, Sean. Below is my code.
>>>
>

Re:Re: Re: Re: Recommend for anonymous users

Posted by Young <wo...@126.com>.
Hi Sean,
Thank you for your reply. 
My items are 100k and users are 100k and each users are expected have 200 ratings and total ratings are 20 million.
Here is the time.
Constructing datamodel using time:150968
Calculating the similarity using time:5
Constructing recommender using time: 5
Please enter user_id
9
Time Used:620ms
Please enter user_id
2
Time Used:369367ms
 
So based on this situation, what should I do next? 
 
 




>That looks basically sound. You probably want to wrap the
>PearsonCorrelationSimilarity in a CachingItemSimilarity.
>
>You may also simply wish to try a different algorithm. What's the data
>like? if it has lots of items, this is not the best choice.
>
>Next step here would be to profile to see where the time is spent. You
>might just debug, and pause the processing periodically to see where
>the thread is. That may show where time is spent.
>
>2010/7/14 Young <wo...@126.com>:
>> Thanks, Sean. Below is my code.
>>

Re: Re: Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
That looks basically sound. You probably want to wrap the
PearsonCorrelationSimilarity in a CachingItemSimilarity.

You may also simply wish to try a different algorithm. What's the data
like? if it has lots of items, this is not the best choice.

Next step here would be to profile to see where the time is spent. You
might just debug, and pause the processing periodically to see where
the thread is. That may show where time is spent.

2010/7/14 Young <wo...@126.com>:
> Thanks, Sean. Below is my code.
>

Re:Re: Re: Recommend for anonymous users

Posted by Young <wo...@126.com>.
Thanks, Sean. Below is my code. 
 

  AbstractJDBCDataModel preference_model = new MySQLJDBCDataModel(ds, table_name, colum1, colum2,colum3);

  DataModel model = new GenericDataModel(preference_model.exportWithPrefs());

  ItemSimilarity itemSimilarity = null;
  try {
   itemSimilarity = new PearsonCorrelationSimilarity(model);
  } catch (TasteException e) {
   e.printStackTrace();
  }  
 
Recommender itembased_recommender = null;
  try {
   itembased_recommender = new CachingRecommender(new GenericItemBasedRecommender(model, itemSimilarity));
  } catch (TasteException e) {
   e.printStackTrace();
  }
  Scanner sc = new Scanner(System.in);
  while (true) {
   String nextLine = sc.nextLine();
    long user_id = 0;
    try {
     user_id = Long.parseLong(nextLine);
    } catch (Exception e) {
     continue;
    }
    long start = System.currentTimeMillis();
    List<RecommendedItem> itembased_items = null;
    try {
     itembased_items = itembased_recommender.recommend(user_id, 10);
    } catch (TasteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    long end = System.currentTimeMillis();
    System.out.println("Time Used:" + (end - start) + "ms");    
   }
  }





>That doesn't sound nearly right -- there must be a problem in your
>implementation. THere is no way a recommendation takes 6 minutes. I am
>guessing you are actually triggering a reload, but even that doesn't
>make sense that it would take so long. You'd have to provide a lot
>more info about your code, algorithm and data to get more comments
>though.
>
>2010/7/14 Young <wo...@126.com>:
>> Hi,
>> I have the same problem. I did not re-compute the similarity of items. But when implementing itembased_recommender.recommend(user_id, 10), time varies a lot.
>> If the user gave 3 ratings, it takes 620ms.
>> If the user gave 30 ratings, it takes 369367ms.
>>
>> How can I do to make it real time recommendation?
>> Thanks very much
>>
>>
>>
>>>Yes, you do not need to refresh this item-item similarity matrix. The
>>>default implementations don't do something like this so I believe you
>>>just need to adjust your process to not recompute this on each new
>>>user.
>>>
>>>It should not be required anyway; a new user entering the system does
>>>not need a refresh of item-item similarity. A new *item* might, but,
>>>it is no big deal to be missing this item for some short time until
>>>the next refresh.
>>>
>>>If you are reloading a large data set periodically you probably want
>>>some system to be constructing the new instance while the old one
>>>serves, then switch instances when the new one is ready. Then it
>>>doesn't matter much how long it takes to load.
>>>
>>>Please show a stack trace for NoSuchUserException, at least the
>>>portion in the library.
>>>
>>>On Tue, Jul 13, 2010 at 6:41 AM, samsam <ya...@gmail.com> wrote:
>>>> Hi again. I'm getting a really hard time to use Taste using the Large 10M
>>>> dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
>>>> I'm assuming a new user has just arrived (not on the user data or item data)
>>>> and starts voting. Trying to refresh the matrix takes over 25 seconds a
>>>> large time when considering a website for instance.
>>>>
>>>> So I found this class. I tried to use it just like shown on javadocs:
>>>>
>>>> PlusAnonymousUserDataModel plusmodel = new
>>>> PlusAnonymousUserDataModel(datamodel);
>>>> PearsonCorrelationSimilarity sim = new
>>>> PearsonCorrelationSimilarity(datamodel);
>>>> Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
>>>> PreferenceArray pref = new GenericUserPreferenceArray(10);
>>>>        pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
>>>>        for(int i=0;i<10;i++){
>>>>            pref.setItemID(i, votes[i][0]);
>>>>            pref.setValue(i,votes[i][1]);
>>>>        }
>>>>        synchronized(pref) {
>>>>            plusmodel.setTempPrefs(pref);
>>>>            recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
>>>> 10);
>>>>        }
>>>>
>>>> But this is causing an NoSuchUserException at the recommender.
>>>>
>>>> I tried using the plusmodel on similarity and recommender instead of the
>>>> realmodel, but did not work as well.
>>>>
>>>>
>>>>
>>>> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>>>>
>>>>> Pre-compute the similarity based on what information? You mention that
>>>>> you don't want to use Pearson and mention item attributes.
>>>>>
>>>>> If you are trying to use domain-specific attributes of items, then
>>>>> it's up to you to write that logic. If you want to say books have a
>>>>> "0.5" similarity when they are within the same genre, and "0.9" when
>>>>> by the same author, you can just write that logic. That's not part of
>>>>> the framework.
>>>>>
>>>>> The hook into the framework comes when you implement ItemSimilarity
>>>>> with logic like that. Then just use that ItemSimilarity instead of one
>>>>> of the given implementations. That's all.
>>>>>
>>>>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>>>> > About the second question,I have not the similarity,I want to know is how
>>>>> to
>>>>> > pre-compute the item similarity.
>>>>> >
>>>>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>>>>> >
>>>>> >> 1) Good question. One answer is to make these "anonymous" users real
>>>>> >> users in your data model, at least temporarily. That is, they need not
>>>>> >> be anonymous to the recommender, even if they're not yet a registered
>>>>> >> user as far as your site is concerned.
>>>>> >>
>>>>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>>>>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>>>>> >> recommend, then un-add that user. It may be the easiest thing to try.
>>>>> >>
>>>>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>>>>> >> current MEAP draft.)
>>>>> >>
>>>>> >> 2) Not sure I fully understand. You already have some external,
>>>>> >> pre-computed notion of item similarity? then just feed that in to
>>>>> >> GenericItemSimilarity and use it from there.
>>>>> >>
>>>>> >> Sean
>>>>> >>
>>>>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>>>>> >> > Hello,all
>>>>> >> > I want to build recommendation engine with apache mahout,I have read
>>>>> some
>>>>> >> > reading material,and I still have some questions.
>>>>> >> >
>>>>> >> > 1)How to recommend for anonymous users
>>>>> >> > I think recommendation engine  should return recommendations given a
>>>>> item
>>>>> >> > id.For example,a anonymous user reviews some items,
>>>>> >> > and tell the recommendation what he reviews,and compute with the
>>>>> reviews
>>>>> >> > histories.
>>>>> >> >
>>>>> >> > 2)How to compute the items similarity dataset
>>>>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>>>>> >> > with PearsonCorrelationSimilarity,but
>>>>> >> > we need to make recommendations with extra attributes of items,
>>>>> >> > so we should use the items similarity dataset,how to build the dataset
>>>>> is
>>>>> >> > the key point.
>>>>> >> > --
>>>>> >> > I'm samsam.
>>>>> >> >
>>>>> >>
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > I'm samsam.
>>>>> >
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> I'm samsam.
>>>>
>>

Re: Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
That doesn't sound nearly right -- there must be a problem in your
implementation. THere is no way a recommendation takes 6 minutes. I am
guessing you are actually triggering a reload, but even that doesn't
make sense that it would take so long. You'd have to provide a lot
more info about your code, algorithm and data to get more comments
though.

2010/7/14 Young <wo...@126.com>:
> Hi,
> I have the same problem. I did not re-compute the similarity of items. But when implementing itembased_recommender.recommend(user_id, 10), time varies a lot.
> If the user gave 3 ratings, it takes 620ms.
> If the user gave 30 ratings, it takes 369367ms.
>
> How can I do to make it real time recommendation?
> Thanks very much
>
>
>
>>Yes, you do not need to refresh this item-item similarity matrix. The
>>default implementations don't do something like this so I believe you
>>just need to adjust your process to not recompute this on each new
>>user.
>>
>>It should not be required anyway; a new user entering the system does
>>not need a refresh of item-item similarity. A new *item* might, but,
>>it is no big deal to be missing this item for some short time until
>>the next refresh.
>>
>>If you are reloading a large data set periodically you probably want
>>some system to be constructing the new instance while the old one
>>serves, then switch instances when the new one is ready. Then it
>>doesn't matter much how long it takes to load.
>>
>>Please show a stack trace for NoSuchUserException, at least the
>>portion in the library.
>>
>>On Tue, Jul 13, 2010 at 6:41 AM, samsam <ya...@gmail.com> wrote:
>>> Hi again. I'm getting a really hard time to use Taste using the Large 10M
>>> dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
>>> I'm assuming a new user has just arrived (not on the user data or item data)
>>> and starts voting. Trying to refresh the matrix takes over 25 seconds a
>>> large time when considering a website for instance.
>>>
>>> So I found this class. I tried to use it just like shown on javadocs:
>>>
>>> PlusAnonymousUserDataModel plusmodel = new
>>> PlusAnonymousUserDataModel(datamodel);
>>> PearsonCorrelationSimilarity sim = new
>>> PearsonCorrelationSimilarity(datamodel);
>>> Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
>>> PreferenceArray pref = new GenericUserPreferenceArray(10);
>>>        pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
>>>        for(int i=0;i<10;i++){
>>>            pref.setItemID(i, votes[i][0]);
>>>            pref.setValue(i,votes[i][1]);
>>>        }
>>>        synchronized(pref) {
>>>            plusmodel.setTempPrefs(pref);
>>>            recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
>>> 10);
>>>        }
>>>
>>> But this is causing an NoSuchUserException at the recommender.
>>>
>>> I tried using the plusmodel on similarity and recommender instead of the
>>> realmodel, but did not work as well.
>>>
>>>
>>>
>>> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>>>
>>>> Pre-compute the similarity based on what information? You mention that
>>>> you don't want to use Pearson and mention item attributes.
>>>>
>>>> If you are trying to use domain-specific attributes of items, then
>>>> it's up to you to write that logic. If you want to say books have a
>>>> "0.5" similarity when they are within the same genre, and "0.9" when
>>>> by the same author, you can just write that logic. That's not part of
>>>> the framework.
>>>>
>>>> The hook into the framework comes when you implement ItemSimilarity
>>>> with logic like that. Then just use that ItemSimilarity instead of one
>>>> of the given implementations. That's all.
>>>>
>>>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>>> > About the second question,I have not the similarity,I want to know is how
>>>> to
>>>> > pre-compute the item similarity.
>>>> >
>>>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>>>> >
>>>> >> 1) Good question. One answer is to make these "anonymous" users real
>>>> >> users in your data model, at least temporarily. That is, they need not
>>>> >> be anonymous to the recommender, even if they're not yet a registered
>>>> >> user as far as your site is concerned.
>>>> >>
>>>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>>>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>>>> >> recommend, then un-add that user. It may be the easiest thing to try.
>>>> >>
>>>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>>>> >> current MEAP draft.)
>>>> >>
>>>> >> 2) Not sure I fully understand. You already have some external,
>>>> >> pre-computed notion of item similarity? then just feed that in to
>>>> >> GenericItemSimilarity and use it from there.
>>>> >>
>>>> >> Sean
>>>> >>
>>>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>>>> >> > Hello,all
>>>> >> > I want to build recommendation engine with apache mahout,I have read
>>>> some
>>>> >> > reading material,and I still have some questions.
>>>> >> >
>>>> >> > 1)How to recommend for anonymous users
>>>> >> > I think recommendation engine  should return recommendations given a
>>>> item
>>>> >> > id.For example,a anonymous user reviews some items,
>>>> >> > and tell the recommendation what he reviews,and compute with the
>>>> reviews
>>>> >> > histories.
>>>> >> >
>>>> >> > 2)How to compute the items similarity dataset
>>>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>>>> >> > with PearsonCorrelationSimilarity,but
>>>> >> > we need to make recommendations with extra attributes of items,
>>>> >> > so we should use the items similarity dataset,how to build the dataset
>>>> is
>>>> >> > the key point.
>>>> >> > --
>>>> >> > I'm samsam.
>>>> >> >
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > I'm samsam.
>>>> >
>>>>
>>>
>>>
>>>
>>> --
>>> I'm samsam.
>>>
>

Re:Re: Recommend for anonymous users

Posted by Young <wo...@126.com>.
Hi,
I have the same problem. I did not re-compute the similarity of items. But when implementing itembased_recommender.recommend(user_id, 10), time varies a lot. 
If the user gave 3 ratings, it takes 620ms.
If the user gave 30 ratings, it takes 369367ms.
 
How can I do to make it real time recommendation?
Thanks very much



>Yes, you do not need to refresh this item-item similarity matrix. The
>default implementations don't do something like this so I believe you
>just need to adjust your process to not recompute this on each new
>user.
>
>It should not be required anyway; a new user entering the system does
>not need a refresh of item-item similarity. A new *item* might, but,
>it is no big deal to be missing this item for some short time until
>the next refresh.
>
>If you are reloading a large data set periodically you probably want
>some system to be constructing the new instance while the old one
>serves, then switch instances when the new one is ready. Then it
>doesn't matter much how long it takes to load.
>
>Please show a stack trace for NoSuchUserException, at least the
>portion in the library.
>
>On Tue, Jul 13, 2010 at 6:41 AM, samsam <ya...@gmail.com> wrote:
>> Hi again. I'm getting a really hard time to use Taste using the Large 10M
>> dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
>> I'm assuming a new user has just arrived (not on the user data or item data)
>> and starts voting. Trying to refresh the matrix takes over 25 seconds a
>> large time when considering a website for instance.
>>
>> So I found this class. I tried to use it just like shown on javadocs:
>>
>> PlusAnonymousUserDataModel plusmodel = new
>> PlusAnonymousUserDataModel(datamodel);
>> PearsonCorrelationSimilarity sim = new
>> PearsonCorrelationSimilarity(datamodel);
>> Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
>> PreferenceArray pref = new GenericUserPreferenceArray(10);
>>        pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
>>        for(int i=0;i<10;i++){
>>            pref.setItemID(i, votes[i][0]);
>>            pref.setValue(i,votes[i][1]);
>>        }
>>        synchronized(pref) {
>>            plusmodel.setTempPrefs(pref);
>>            recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
>> 10);
>>        }
>>
>> But this is causing an NoSuchUserException at the recommender.
>>
>> I tried using the plusmodel on similarity and recommender instead of the
>> realmodel, but did not work as well.
>>
>>
>>
>> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>>
>>> Pre-compute the similarity based on what information? You mention that
>>> you don't want to use Pearson and mention item attributes.
>>>
>>> If you are trying to use domain-specific attributes of items, then
>>> it's up to you to write that logic. If you want to say books have a
>>> "0.5" similarity when they are within the same genre, and "0.9" when
>>> by the same author, you can just write that logic. That's not part of
>>> the framework.
>>>
>>> The hook into the framework comes when you implement ItemSimilarity
>>> with logic like that. Then just use that ItemSimilarity instead of one
>>> of the given implementations. That's all.
>>>
>>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>> > About the second question,I have not the similarity,I want to know is how
>>> to
>>> > pre-compute the item similarity.
>>> >
>>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>>> >
>>> >> 1) Good question. One answer is to make these "anonymous" users real
>>> >> users in your data model, at least temporarily. That is, they need not
>>> >> be anonymous to the recommender, even if they're not yet a registered
>>> >> user as far as your site is concerned.
>>> >>
>>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>>> >> recommend, then un-add that user. It may be the easiest thing to try.
>>> >>
>>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>>> >> current MEAP draft.)
>>> >>
>>> >> 2) Not sure I fully understand. You already have some external,
>>> >> pre-computed notion of item similarity? then just feed that in to
>>> >> GenericItemSimilarity and use it from there.
>>> >>
>>> >> Sean
>>> >>
>>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>>> >> > Hello,all
>>> >> > I want to build recommendation engine with apache mahout,I have read
>>> some
>>> >> > reading material,and I still have some questions.
>>> >> >
>>> >> > 1)How to recommend for anonymous users
>>> >> > I think recommendation engine  should return recommendations given a
>>> item
>>> >> > id.For example,a anonymous user reviews some items,
>>> >> > and tell the recommendation what he reviews,and compute with the
>>> reviews
>>> >> > histories.
>>> >> >
>>> >> > 2)How to compute the items similarity dataset
>>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>>> >> > with PearsonCorrelationSimilarity,but
>>> >> > we need to make recommendations with extra attributes of items,
>>> >> > so we should use the items similarity dataset,how to build the dataset
>>> is
>>> >> > the key point.
>>> >> > --
>>> >> > I'm samsam.
>>> >> >
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > I'm samsam.
>>> >
>>>
>>
>>
>>
>> --
>> I'm samsam.
>>

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
Yes, you do not need to refresh this item-item similarity matrix. The
default implementations don't do something like this so I believe you
just need to adjust your process to not recompute this on each new
user.

It should not be required anyway; a new user entering the system does
not need a refresh of item-item similarity. A new *item* might, but,
it is no big deal to be missing this item for some short time until
the next refresh.

If you are reloading a large data set periodically you probably want
some system to be constructing the new instance while the old one
serves, then switch instances when the new one is ready. Then it
doesn't matter much how long it takes to load.

Please show a stack trace for NoSuchUserException, at least the
portion in the library.

On Tue, Jul 13, 2010 at 6:41 AM, samsam <ya...@gmail.com> wrote:
> Hi again. I'm getting a really hard time to use Taste using the Large 10M
> dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
> I'm assuming a new user has just arrived (not on the user data or item data)
> and starts voting. Trying to refresh the matrix takes over 25 seconds a
> large time when considering a website for instance.
>
> So I found this class. I tried to use it just like shown on javadocs:
>
> PlusAnonymousUserDataModel plusmodel = new
> PlusAnonymousUserDataModel(datamodel);
> PearsonCorrelationSimilarity sim = new
> PearsonCorrelationSimilarity(datamodel);
> Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
> PreferenceArray pref = new GenericUserPreferenceArray(10);
>        pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
>        for(int i=0;i<10;i++){
>            pref.setItemID(i, votes[i][0]);
>            pref.setValue(i,votes[i][1]);
>        }
>        synchronized(pref) {
>            plusmodel.setTempPrefs(pref);
>            recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
> 10);
>        }
>
> But this is causing an NoSuchUserException at the recommender.
>
> I tried using the plusmodel on similarity and recommender instead of the
> realmodel, but did not work as well.
>
>
>
> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>
>> Pre-compute the similarity based on what information? You mention that
>> you don't want to use Pearson and mention item attributes.
>>
>> If you are trying to use domain-specific attributes of items, then
>> it's up to you to write that logic. If you want to say books have a
>> "0.5" similarity when they are within the same genre, and "0.9" when
>> by the same author, you can just write that logic. That's not part of
>> the framework.
>>
>> The hook into the framework comes when you implement ItemSimilarity
>> with logic like that. Then just use that ItemSimilarity instead of one
>> of the given implementations. That's all.
>>
>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>> > About the second question,I have not the similarity,I want to know is how
>> to
>> > pre-compute the item similarity.
>> >
>> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>> >
>> >> 1) Good question. One answer is to make these "anonymous" users real
>> >> users in your data model, at least temporarily. That is, they need not
>> >> be anonymous to the recommender, even if they're not yet a registered
>> >> user as far as your site is concerned.
>> >>
>> >> There's a class called PlusAnonymousUserDataModel that helps you do
>> >> this. It wraps a DataModel and lets you quickly add a temporary user,
>> >> recommend, then un-add that user. It may be the easiest thing to try.
>> >>
>> >> (BTW the book Mahout in Action covers this in section 5.4, in the
>> >> current MEAP draft.)
>> >>
>> >> 2) Not sure I fully understand. You already have some external,
>> >> pre-computed notion of item similarity? then just feed that in to
>> >> GenericItemSimilarity and use it from there.
>> >>
>> >> Sean
>> >>
>> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>> >> > Hello,all
>> >> > I want to build recommendation engine with apache mahout,I have read
>> some
>> >> > reading material,and I still have some questions.
>> >> >
>> >> > 1)How to recommend for anonymous users
>> >> > I think recommendation engine  should return recommendations given a
>> item
>> >> > id.For example,a anonymous user reviews some items,
>> >> > and tell the recommendation what he reviews,and compute with the
>> reviews
>> >> > histories.
>> >> >
>> >> > 2)How to compute the items similarity dataset
>> >> > Without use items similarity dataset,we can make ItemBasedRecommender
>> >> > with PearsonCorrelationSimilarity,but
>> >> > we need to make recommendations with extra attributes of items,
>> >> > so we should use the items similarity dataset,how to build the dataset
>> is
>> >> > the key point.
>> >> > --
>> >> > I'm samsam.
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > I'm samsam.
>> >
>>
>
>
>
> --
> I'm samsam.
>

Fail when converting Weka's ARFF (2.1) format to Mahout's Vector format.

Posted by Sonia Ben Ticha <be...@gnet.tn>.
Hello,
I have run the converter to convert a Weka ARFF file to a Mahout Vector , the weka file contains a missing(represent with '?' in weka) but the program failed and display the following error message:
   Exception in thread "main" java.lang.NumberFormatException : for input string : "?"

Questions?
1) Why the converter don't accept missing value ('?')? 
2) How can I convert a data file (movie lens) to vector to execute the fuzzy kmean algorithm? 

Thank you
Sonia



Re: Recommend for anonymous users

Posted by Sebastian Schelter <ss...@googlemail.com>.
Hi Sansam,

You could try to precompute the similarity matrix and use a
FileItemSimilarity to load it into memory. Have a look at "bin/mahout
itemsimilarity".

Hope that helps.

--sebastian

Am 13.07.2010 07:41, schrieb samsam:
> Hi again. I'm getting a really hard time to use Taste using the Large 10M
> dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
> I'm assuming a new user has just arrived (not on the user data or item data)
> and starts voting. Trying to refresh the matrix takes over 25 seconds a
> large time when considering a website for instance.
>
> So I found this class. I tried to use it just like shown on javadocs:
>
> PlusAnonymousUserDataModel plusmodel = new
> PlusAnonymousUserDataModel(datamodel);
> PearsonCorrelationSimilarity sim = new
> PearsonCorrelationSimilarity(datamodel);
> Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
> PreferenceArray pref = new GenericUserPreferenceArray(10);
>         pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
>         for(int i=0;i<10;i++){
>             pref.setItemID(i, votes[i][0]);
>             pref.setValue(i,votes[i][1]);
>         }
>         synchronized(pref) {
>             plusmodel.setTempPrefs(pref);
>             recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
> 10);
>         }
>
> But this is causing an NoSuchUserException at the recommender.
>
> I tried using the plusmodel on similarity and recommender instead of the
> realmodel, but did not work as well.
>
>
>
> On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:
>
>   
>> Pre-compute the similarity based on what information? You mention that
>> you don't want to use Pearson and mention item attributes.
>>
>> If you are trying to use domain-specific attributes of items, then
>> it's up to you to write that logic. If you want to say books have a
>> "0.5" similarity when they are within the same genre, and "0.9" when
>> by the same author, you can just write that logic. That's not part of
>> the framework.
>>
>> The hook into the framework comes when you implement ItemSimilarity
>> with logic like that. Then just use that ItemSimilarity instead of one
>> of the given implementations. That's all.
>>
>> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
>>     
>>> About the second question,I have not the similarity,I want to know is how
>>>       
>> to
>>     
>>> pre-compute the item similarity.
>>>
>>> On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>>>
>>>       
>>>> 1) Good question. One answer is to make these "anonymous" users real
>>>> users in your data model, at least temporarily. That is, they need not
>>>> be anonymous to the recommender, even if they're not yet a registered
>>>> user as far as your site is concerned.
>>>>
>>>> There's a class called PlusAnonymousUserDataModel that helps you do
>>>> this. It wraps a DataModel and lets you quickly add a temporary user,
>>>> recommend, then un-add that user. It may be the easiest thing to try.
>>>>
>>>> (BTW the book Mahout in Action covers this in section 5.4, in the
>>>> current MEAP draft.)
>>>>
>>>> 2) Not sure I fully understand. You already have some external,
>>>> pre-computed notion of item similarity? then just feed that in to
>>>> GenericItemSimilarity and use it from there.
>>>>
>>>> Sean
>>>>
>>>> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>>>>         
>>>>> Hello,all
>>>>> I want to build recommendation engine with apache mahout,I have read
>>>>>           
>> some
>>     
>>>>> reading material,and I still have some questions.
>>>>>
>>>>> 1)How to recommend for anonymous users
>>>>> I think recommendation engine  should return recommendations given a
>>>>>           
>> item
>>     
>>>>> id.For example,a anonymous user reviews some items,
>>>>> and tell the recommendation what he reviews,and compute with the
>>>>>           
>> reviews
>>     
>>>>> histories.
>>>>>
>>>>> 2)How to compute the items similarity dataset
>>>>> Without use items similarity dataset,we can make ItemBasedRecommender
>>>>> with PearsonCorrelationSimilarity,but
>>>>> we need to make recommendations with extra attributes of items,
>>>>> so we should use the items similarity dataset,how to build the dataset
>>>>>           
>> is
>>     
>>>>> the key point.
>>>>> --
>>>>> I'm samsam.
>>>>>
>>>>>           
>>>>         
>>>
>>>
>>> --
>>> I'm samsam.
>>>
>>>       
>>     
>
>
>   


Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
Hi again. I'm getting a really hard time to use Taste using the Large 10M
dataset. Using FileDataModel is taking too long to recompute the sim-matrix.
I'm assuming a new user has just arrived (not on the user data or item data)
and starts voting. Trying to refresh the matrix takes over 25 seconds a
large time when considering a website for instance.

So I found this class. I tried to use it just like shown on javadocs:

PlusAnonymousUserDataModel plusmodel = new
PlusAnonymousUserDataModel(datamodel);
PearsonCorrelationSimilarity sim = new
PearsonCorrelationSimilarity(datamodel);
Recommender recommender = new GenericItemBasedRecommender(datamodel,sim);
PreferenceArray pref = new GenericUserPreferenceArray(10);
        pref.setUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
        for(int i=0;i<10;i++){
            pref.setItemID(i, votes[i][0]);
            pref.setValue(i,votes[i][1]);
        }
        synchronized(pref) {
            plusmodel.setTempPrefs(pref);
            recommender.recommend(PlusAnonymousUserDataModel.TEMP_USER_ID,
10);
        }

But this is causing an NoSuchUserException at the recommender.

I tried using the plusmodel on similarity and recommender instead of the
realmodel, but did not work as well.



On Mon, Jul 5, 2010 at 11:52 PM, Sean Owen <sr...@gmail.com> wrote:

> Pre-compute the similarity based on what information? You mention that
> you don't want to use Pearson and mention item attributes.
>
> If you are trying to use domain-specific attributes of items, then
> it's up to you to write that logic. If you want to say books have a
> "0.5" similarity when they are within the same genre, and "0.9" when
> by the same author, you can just write that logic. That's not part of
> the framework.
>
> The hook into the framework comes when you implement ItemSimilarity
> with logic like that. Then just use that ItemSimilarity instead of one
> of the given implementations. That's all.
>
> On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
> > About the second question,I have not the similarity,I want to know is how
> to
> > pre-compute the item similarity.
> >
> > On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
> >
> >> 1) Good question. One answer is to make these "anonymous" users real
> >> users in your data model, at least temporarily. That is, they need not
> >> be anonymous to the recommender, even if they're not yet a registered
> >> user as far as your site is concerned.
> >>
> >> There's a class called PlusAnonymousUserDataModel that helps you do
> >> this. It wraps a DataModel and lets you quickly add a temporary user,
> >> recommend, then un-add that user. It may be the easiest thing to try.
> >>
> >> (BTW the book Mahout in Action covers this in section 5.4, in the
> >> current MEAP draft.)
> >>
> >> 2) Not sure I fully understand. You already have some external,
> >> pre-computed notion of item similarity? then just feed that in to
> >> GenericItemSimilarity and use it from there.
> >>
> >> Sean
> >>
> >> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
> >> > Hello,all
> >> > I want to build recommendation engine with apache mahout,I have read
> some
> >> > reading material,and I still have some questions.
> >> >
> >> > 1)How to recommend for anonymous users
> >> > I think recommendation engine  should return recommendations given a
> item
> >> > id.For example,a anonymous user reviews some items,
> >> > and tell the recommendation what he reviews,and compute with the
> reviews
> >> > histories.
> >> >
> >> > 2)How to compute the items similarity dataset
> >> > Without use items similarity dataset,we can make ItemBasedRecommender
> >> > with PearsonCorrelationSimilarity,but
> >> > we need to make recommendations with extra attributes of items,
> >> > so we should use the items similarity dataset,how to build the dataset
> is
> >> > the key point.
> >> > --
> >> > I'm samsam.
> >> >
> >>
> >
> >
> >
> > --
> > I'm samsam.
> >
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
Pre-compute the similarity based on what information? You mention that
you don't want to use Pearson and mention item attributes.

If you are trying to use domain-specific attributes of items, then
it's up to you to write that logic. If you want to say books have a
"0.5" similarity when they are within the same genre, and "0.9" when
by the same author, you can just write that logic. That's not part of
the framework.

The hook into the framework comes when you implement ItemSimilarity
with logic like that. Then just use that ItemSimilarity instead of one
of the given implementations. That's all.

On Mon, Jul 5, 2010 at 4:32 PM, samsam <ya...@gmail.com> wrote:
> About the second question,I have not the similarity,I want to know is how to
> pre-compute the item similarity.
>
> On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:
>
>> 1) Good question. One answer is to make these "anonymous" users real
>> users in your data model, at least temporarily. That is, they need not
>> be anonymous to the recommender, even if they're not yet a registered
>> user as far as your site is concerned.
>>
>> There's a class called PlusAnonymousUserDataModel that helps you do
>> this. It wraps a DataModel and lets you quickly add a temporary user,
>> recommend, then un-add that user. It may be the easiest thing to try.
>>
>> (BTW the book Mahout in Action covers this in section 5.4, in the
>> current MEAP draft.)
>>
>> 2) Not sure I fully understand. You already have some external,
>> pre-computed notion of item similarity? then just feed that in to
>> GenericItemSimilarity and use it from there.
>>
>> Sean
>>
>> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
>> > Hello,all
>> > I want to build recommendation engine with apache mahout,I have read some
>> > reading material,and I still have some questions.
>> >
>> > 1)How to recommend for anonymous users
>> > I think recommendation engine  should return recommendations given a item
>> > id.For example,a anonymous user reviews some items,
>> > and tell the recommendation what he reviews,and compute with the reviews
>> > histories.
>> >
>> > 2)How to compute the items similarity dataset
>> > Without use items similarity dataset,we can make ItemBasedRecommender
>> > with PearsonCorrelationSimilarity,but
>> > we need to make recommendations with extra attributes of items,
>> > so we should use the items similarity dataset,how to build the dataset is
>> > the key point.
>> > --
>> > I'm samsam.
>> >
>>
>
>
>
> --
> I'm samsam.
>

Re: Recommend for anonymous users

Posted by samsam <ya...@gmail.com>.
About the second question,I have not the similarity,I want to know is how to
pre-compute the item similarity.

On Mon, Jul 5, 2010 at 11:20 PM, Sean Owen <sr...@gmail.com> wrote:

> 1) Good question. One answer is to make these "anonymous" users real
> users in your data model, at least temporarily. That is, they need not
> be anonymous to the recommender, even if they're not yet a registered
> user as far as your site is concerned.
>
> There's a class called PlusAnonymousUserDataModel that helps you do
> this. It wraps a DataModel and lets you quickly add a temporary user,
> recommend, then un-add that user. It may be the easiest thing to try.
>
> (BTW the book Mahout in Action covers this in section 5.4, in the
> current MEAP draft.)
>
> 2) Not sure I fully understand. You already have some external,
> pre-computed notion of item similarity? then just feed that in to
> GenericItemSimilarity and use it from there.
>
> Sean
>
> On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
> > Hello,all
> > I want to build recommendation engine with apache mahout,I have read some
> > reading material,and I still have some questions.
> >
> > 1)How to recommend for anonymous users
> > I think recommendation engine  should return recommendations given a item
> > id.For example,a anonymous user reviews some items,
> > and tell the recommendation what he reviews,and compute with the reviews
> > histories.
> >
> > 2)How to compute the items similarity dataset
> > Without use items similarity dataset,we can make ItemBasedRecommender
> > with PearsonCorrelationSimilarity,but
> > we need to make recommendations with extra attributes of items,
> > so we should use the items similarity dataset,how to build the dataset is
> > the key point.
> > --
> > I'm samsam.
> >
>



-- 
I'm samsam.

Re: Recommend for anonymous users

Posted by Sean Owen <sr...@gmail.com>.
1) Good question. One answer is to make these "anonymous" users real
users in your data model, at least temporarily. That is, they need not
be anonymous to the recommender, even if they're not yet a registered
user as far as your site is concerned.

There's a class called PlusAnonymousUserDataModel that helps you do
this. It wraps a DataModel and lets you quickly add a temporary user,
recommend, then un-add that user. It may be the easiest thing to try.

(BTW the book Mahout in Action covers this in section 5.4, in the
current MEAP draft.)

2) Not sure I fully understand. You already have some external,
pre-computed notion of item similarity? then just feed that in to
GenericItemSimilarity and use it from there.

Sean

On Mon, Jul 5, 2010 at 1:52 PM, samsam <ya...@gmail.com> wrote:
> Hello,all
> I want to build recommendation engine with apache mahout,I have read some
> reading material,and I still have some questions.
>
> 1)How to recommend for anonymous users
> I think recommendation engine  should return recommendations given a item
> id.For example,a anonymous user reviews some items,
> and tell the recommendation what he reviews,and compute with the reviews
> histories.
>
> 2)How to compute the items similarity dataset
> Without use items similarity dataset,we can make ItemBasedRecommender
> with PearsonCorrelationSimilarity,but
> we need to make recommendations with extra attributes of items,
> so we should use the items similarity dataset,how to build the dataset is
> the key point.
> --
> I'm samsam.
>