You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by huangjia <cu...@gmail.com> on 2013/05/16 03:19:34 UTC
How to extend FileDataModel
Hi,
I want to build a recommendation model based on Mahout. My dataset format
is in the format of
userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need to
extend the FileDataModel.
I looked into *JesterDataModel* as an example. However, I have a problem
with the logic flow. In its *buildModel()* method, an empty map "data" is
first constructed. It is then thrown into processFile. I assume that "data"
is modified in this method, since later it is used to construct the
GenericDataModel. However, "data" is a local variable instead of a class
variable, so how is it modified?
processFile(iterator, data, timestamps, false);
return new GenericDataModel(GenericDataModel.toDataMap(data, true));
--
Jia
Re: How to extend FileDataModel
Posted by huangjia <cu...@gmail.com>.
A follow-up question.
I worked around for quite a while and got stuck. It is difficult for me to
figure out which are the classes I need to extend.
I suppose they are : FileDataModel, Preference, PreferenceArray, am I
correct?
Thanks!
Jia
On Fri, May 17, 2013 at 1:20 AM, Manuel Blechschmidt <
Manuel.Blechschmidt@gmx.de> wrote:
> Yes Jia, that is correct.
>
> If you want to save additional data (context) then you have to extend the
> current data models. The current algorithms won't use the additional data.
> If you want to be able to integrate I would recommend that you search for
> "contextaware recommender" e.g.
> http://recsyswiki.com/wiki/Context-aware_recommendation
>
> /Manuel
>
> Am 16.05.2013 um 20:42 schrieb huangjia:
>
> > Thanks to both of you!
> >
> >
> > Manuel.
> > It seems that your code directly use GenericDataModel without including
> > extra fields such as category and time.
> > So I still need to extend the GenericDataModel if I want to include tags,
> > right?
> >
> > Thanks again,
> >
> > Jia
> >
> >
> > On Thu, May 16, 2013 at 12:56 AM, Manuel Blechschmidt <
> > Manuel.Blechschmidt@gmx.de> wrote:
> >
> >> Hi Jia,
> >> checkout the following example which is used to build a data model from
> a
> >> similar dataset like yours:
> >>
> >>
> >>
> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/java/de/apaxo/bedcon/FacebookRecommender.java#L139
> >>
> >> Dataset:
> >>
> >>
> >>
> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/resources/DemoFriendsLikes.csv
> >>
> >> Hope that helps
> >> Manuel
> >>
> >> Am 16.05.2013 um 03:19 schrieb huangjia:
> >>
> >>> Hi,
> >>>
> >>> I want to build a recommendation model based on Mahout. My dataset
> format
> >>> is in the format of
> >>>
> >>> userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need
> to
> >>> extend the FileDataModel.
> >>>
> >>> I looked into *JesterDataModel* as an example. However, I have a
> problem
> >>> with the logic flow. In its *buildModel()* method, an empty map "data"
> is
> >>> first constructed. It is then thrown into processFile. I assume that
> >> "data"
> >>> is modified in this method, since later it is used to construct the
> >>> GenericDataModel. However, "data" is a local variable instead of a
> class
> >>> variable, so how is it modified?
> >>>
> >>> processFile(iterator, data, timestamps, false);
> >>> return new GenericDataModel(GenericDataModel.toDataMap(data, true));
> >>>
> >>>
> >>> --
> >>> Jia
> >>
> >> --
> >> Manuel Blechschmidt
> >> M.Sc. IT Systems Engineering
> >> Dortustr. 57
> >> 14467 Potsdam
> >> Mobil: 0173/6322621
> >> Twitter: http://twitter.com/Manuel_B
> >>
> >>
> >
> >
> > --
> > Jia Huang
> > PhD student
> > College of Information Science & Technology
> > Drexel University
>
> --
> Manuel Blechschmidt
> M.Sc. IT Systems Engineering
> Dortustr. 57
> 14467 Potsdam
> Mobil: 0173/6322621
> Twitter: http://twitter.com/Manuel_B
>
>
--
Jia Huang
PhD student
College of Information Science & Technology
Drexel University
Re: How to extend FileDataModel
Posted by Manuel Blechschmidt <Ma...@gmx.de>.
Yes Jia, that is correct.
If you want to save additional data (context) then you have to extend the current data models. The current algorithms won't use the additional data. If you want to be able to integrate I would recommend that you search for "contextaware recommender" e.g. http://recsyswiki.com/wiki/Context-aware_recommendation
/Manuel
Am 16.05.2013 um 20:42 schrieb huangjia:
> Thanks to both of you!
>
>
> Manuel.
> It seems that your code directly use GenericDataModel without including
> extra fields such as category and time.
> So I still need to extend the GenericDataModel if I want to include tags,
> right?
>
> Thanks again,
>
> Jia
>
>
> On Thu, May 16, 2013 at 12:56 AM, Manuel Blechschmidt <
> Manuel.Blechschmidt@gmx.de> wrote:
>
>> Hi Jia,
>> checkout the following example which is used to build a data model from a
>> similar dataset like yours:
>>
>>
>> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/java/de/apaxo/bedcon/FacebookRecommender.java#L139
>>
>> Dataset:
>>
>>
>> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/resources/DemoFriendsLikes.csv
>>
>> Hope that helps
>> Manuel
>>
>> Am 16.05.2013 um 03:19 schrieb huangjia:
>>
>>> Hi,
>>>
>>> I want to build a recommendation model based on Mahout. My dataset format
>>> is in the format of
>>>
>>> userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need to
>>> extend the FileDataModel.
>>>
>>> I looked into *JesterDataModel* as an example. However, I have a problem
>>> with the logic flow. In its *buildModel()* method, an empty map "data" is
>>> first constructed. It is then thrown into processFile. I assume that
>> "data"
>>> is modified in this method, since later it is used to construct the
>>> GenericDataModel. However, "data" is a local variable instead of a class
>>> variable, so how is it modified?
>>>
>>> processFile(iterator, data, timestamps, false);
>>> return new GenericDataModel(GenericDataModel.toDataMap(data, true));
>>>
>>>
>>> --
>>> Jia
>>
>> --
>> Manuel Blechschmidt
>> M.Sc. IT Systems Engineering
>> Dortustr. 57
>> 14467 Potsdam
>> Mobil: 0173/6322621
>> Twitter: http://twitter.com/Manuel_B
>>
>>
>
>
> --
> Jia Huang
> PhD student
> College of Information Science & Technology
> Drexel University
--
Manuel Blechschmidt
M.Sc. IT Systems Engineering
Dortustr. 57
14467 Potsdam
Mobil: 0173/6322621
Twitter: http://twitter.com/Manuel_B
Re: How to extend FileDataModel
Posted by huangjia <cu...@gmail.com>.
Thanks to both of you!
Manuel.
It seems that your code directly use GenericDataModel without including
extra fields such as category and time.
So I still need to extend the GenericDataModel if I want to include tags,
right?
Thanks again,
Jia
On Thu, May 16, 2013 at 12:56 AM, Manuel Blechschmidt <
Manuel.Blechschmidt@gmx.de> wrote:
> Hi Jia,
> checkout the following example which is used to build a data model from a
> similar dataset like yours:
>
>
> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/java/de/apaxo/bedcon/FacebookRecommender.java#L139
>
> Dataset:
>
>
> https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/resources/DemoFriendsLikes.csv
>
> Hope that helps
> Manuel
>
> Am 16.05.2013 um 03:19 schrieb huangjia:
>
> > Hi,
> >
> > I want to build a recommendation model based on Mahout. My dataset format
> > is in the format of
> >
> > userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need to
> > extend the FileDataModel.
> >
> > I looked into *JesterDataModel* as an example. However, I have a problem
> > with the logic flow. In its *buildModel()* method, an empty map "data" is
> > first constructed. It is then thrown into processFile. I assume that
> "data"
> > is modified in this method, since later it is used to construct the
> > GenericDataModel. However, "data" is a local variable instead of a class
> > variable, so how is it modified?
> >
> > processFile(iterator, data, timestamps, false);
> > return new GenericDataModel(GenericDataModel.toDataMap(data, true));
> >
> >
> > --
> > Jia
>
> --
> Manuel Blechschmidt
> M.Sc. IT Systems Engineering
> Dortustr. 57
> 14467 Potsdam
> Mobil: 0173/6322621
> Twitter: http://twitter.com/Manuel_B
>
>
--
Jia Huang
PhD student
College of Information Science & Technology
Drexel University
Re: How to extend FileDataModel
Posted by Manuel Blechschmidt <Ma...@gmx.de>.
Hi Jia,
checkout the following example which is used to build a data model from a similar dataset like yours:
https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/java/de/apaxo/bedcon/FacebookRecommender.java#L139
Dataset:
https://github.com/ManuelB/facebook-recommender-demo/blob/master/src/main/resources/DemoFriendsLikes.csv
Hope that helps
Manuel
Am 16.05.2013 um 03:19 schrieb huangjia:
> Hi,
>
> I want to build a recommendation model based on Mahout. My dataset format
> is in the format of
>
> userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need to
> extend the FileDataModel.
>
> I looked into *JesterDataModel* as an example. However, I have a problem
> with the logic flow. In its *buildModel()* method, an empty map "data" is
> first constructed. It is then thrown into processFile. I assume that "data"
> is modified in this method, since later it is used to construct the
> GenericDataModel. However, "data" is a local variable instead of a class
> variable, so how is it modified?
>
> processFile(iterator, data, timestamps, false);
> return new GenericDataModel(GenericDataModel.toDataMap(data, true));
>
>
> --
> Jia
--
Manuel Blechschmidt
M.Sc. IT Systems Engineering
Dortustr. 57
14467 Potsdam
Mobil: 0173/6322621
Twitter: http://twitter.com/Manuel_B
Re: How to extend FileDataModel
Posted by Sean Owen <sr...@gmail.com>.
Why not? it's just the object reference that is local to the function.
The Map itself is not, and on the heap like everything else in the
JVM.
On Thu, May 16, 2013 at 2:19 AM, huangjia <cu...@gmail.com> wrote:
> Hi,
>
> I want to build a recommendation model based on Mahout. My dataset format
> is in the format of
>
> userID, itemID, rating timestamp tag1 tag2 tag3. Thus, I think I need to
> extend the FileDataModel.
>
> I looked into *JesterDataModel* as an example. However, I have a problem
> with the logic flow. In its *buildModel()* method, an empty map "data" is
> first constructed. It is then thrown into processFile. I assume that "data"
> is modified in this method, since later it is used to construct the
> GenericDataModel. However, "data" is a local variable instead of a class
> variable, so how is it modified?
>
> processFile(iterator, data, timestamps, false);
> return new GenericDataModel(GenericDataModel.toDataMap(data, true));
>
>
> --
> Jia