You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Matthew Runo <ma...@gmail.com> on 2011/02/04 23:33:08 UTC

Getting itemIDs out of a dataModel?

Hello -

I took a quick stab at precomputing item-item similarities recently,
and it seems like I'm not getting the itemIDs that I should be:

 Iterator iter = dataModel.getItemIDs();
 while( iter.hasNext() ){
    long item1 = (Long) iter.next();

    Iterator inner = dataModel.getItemIDs();
    while( inner.hasNext() ){
        long item2 = (Long) inner.next();
        cache.add(
                  new GenericItemSimilarity.ItemItemSimilarity(item1,
item2, itemSimilarity.itemSimilarity(item1, item2))
                );
...

I get an itemID that is not found in my input data at all. I do,
however, find it as a userID. My data is currently a flat file:

itemID,userID,time,pref

for example..

705540,3472328326359560240,1288681200,10

I can only assume that this is not the proper way to loop through all
the itemIDs inside the dataModel. How would you do that? I'd expect to
get 705540 from the line above..

Thanks for your time!

Matthew Runo

Re: Getting itemIDs out of a dataModel?

Posted by Sean Owen <sr...@gmail.com>.
Nope, it's always been user ID - item ID. However FileDataModel has a
boolean switch which lets you flip the two if you like.

On Fri, Feb 4, 2011 at 10:36 PM, Matthew Runo <ma...@gmail.com>wrote:

> Nevermind. I see now that the userID is supposed to come first. Did
> this change recently? I'm on 0.5-SNAPSHOT.. and I could swear it used
> to be itemID first..
>
>

Re: Getting itemIDs out of a dataModel?

Posted by Matthew Runo <ma...@gmail.com>.
Nevermind. I see now that the userID is supposed to come first. Did
this change recently? I'm on 0.5-SNAPSHOT.. and I could swear it used
to be itemID first..

--Matthew

On Fri, Feb 4, 2011 at 2:33 PM, Matthew Runo <ma...@gmail.com> wrote:
> Hello -
>
> I took a quick stab at precomputing item-item similarities recently,
> and it seems like I'm not getting the itemIDs that I should be:
>
>  Iterator iter = dataModel.getItemIDs();
>  while( iter.hasNext() ){
>    long item1 = (Long) iter.next();
>
>    Iterator inner = dataModel.getItemIDs();
>    while( inner.hasNext() ){
>        long item2 = (Long) inner.next();
>        cache.add(
>                  new GenericItemSimilarity.ItemItemSimilarity(item1,
> item2, itemSimilarity.itemSimilarity(item1, item2))
>                );
> ...
>
> I get an itemID that is not found in my input data at all. I do,
> however, find it as a userID. My data is currently a flat file:
>
> itemID,userID,time,pref
>
> for example..
>
> 705540,3472328326359560240,1288681200,10
>
> I can only assume that this is not the proper way to loop through all
> the itemIDs inside the dataModel. How would you do that? I'd expect to
> get 705540 from the line above..
>
> Thanks for your time!
>
> Matthew Runo
>