It looks fine except that you have this in the constructor -- why?
               LoadEvaluator.runLoad(delegate);
               List<RecommendedItem> recommendations = delegate.recommend(1,1);


               for (RecommendedItem recommendation : recommendations){
                       System.out.println(recommendation);
               }

This happens outside, in other code running an eval.

Again, you probably want to look at the examples in the book, which
walk through this.

On Mon, Nov 22, 2010 at 4:32 PM, Stefano Bellasio
<[email protected]> wrote:
>
> Well, guys i wrote this code, can you tell me if it's right or not?
> Thanks in advance :)
>
> package org.apache.mahout.cf.taste.hadoop.item;
> import org.apache.mahout.cf.taste.common.Refreshable;
> import org.apache.mahout.cf.taste.common.TasteException;
> import org.apache.mahout.cf.taste.example.grouplens.GroupLensDataModel;
> import org.apache.mahout.cf.taste.impl.eval.LoadEvaluator;
> import org.apache.mahout.cf.taste.impl.model.file.*;
> import org.apache.mahout.cf.taste.impl.recommender.*;
> import org.apache.mahout.cf.taste.impl.recommender.svd.SVDRecommender;
> import org.apache.mahout.cf.taste.impl.similarity.*;
> import org.apache.mahout.cf.taste.model.*;
> import org.apache.mahout.cf.taste.recommender.*;
> import org.apache.mahout.cf.taste.similarity.*;
> import java.io.*;
> import java.util.*;
> public class ItemBased implements Recommender {
>
>
>                private final Recommender delegate;
>                private DataModel model;
>
>                public ItemBased(DataModel model) throws TasteException, 
> IOException {
>
>                ItemSimilarity similarity = new 
> PearsonCorrelationSimilarity(model);
>
>
>                delegate = new GenericItemBasedRecommender(model, similarity);
>                LoadEvaluator.runLoad(delegate);
>                List<RecommendedItem> recommendations = 
> delegate.recommend(1,1);
>
>
>                for (RecommendedItem recommendation : recommendations){
>                        System.out.println(recommendation);
>                }
> }
>               �...@override
>                public float estimatePreference(long userID, long itemID)
>                                throws TasteException {
>                        // TODO Auto-generated method stub
>                        return delegate.estimatePreference(userID, itemID);
>                }
>               �...@override
>                public DataModel getDataModel() {
>                        return delegate.getDataModel();
>                }
>               �...@override
>                public List<RecommendedItem> recommend(long userID, int 
> howMany)
>                                throws TasteException {
>                        return delegate.recommend(userID, howMany);
>                }
>               �...@override
>                public List<RecommendedItem> recommend(long userID, int 
> howMany,
>                                IDRescorer rescorer) throws TasteException {
>                        // TODO Auto-generated method stub
>                        return delegate.recommend(userID, howMany);
>                }
>               �...@override
>                public void removePreference(long userID, long itemID)
>                                throws TasteException {
>                        // TODO Auto-generated method stub
>
>                }
>               �...@override
>                public void setPreference(long userID, long itemID, float 
> value)
>                                throws TasteException {
>                        delegate.setPreference(userID, itemID, value);
>
>                }
>               �...@override
>                public void refresh(Collection<Refreshable> alreadyRefreshed) {
>
>                        delegate.refresh(alreadyRefreshed);
>
>                }
> }
> Il giorno 21/nov/2010, alle ore 07.49, web service ha scritto:
>
> > Well, I did run the grouplensrecommender on hadoop.Most of the time the
> > problem I encountered (like exceptions of yours) was packing the libs,
> > creating jar and configuring input paths. As Sean said, look at
> > GroupLensRecommender implementation in
> > o.a.m.c.t.example.grouplens.GroupLensRecommender.
> >
> > HTH
> >
> >
> > On Sat, Nov 20, 2010 at 7:11 AM, Sean Owen <[email protected]> wrote:
> >
> >> The first part looks right, but you have not delegated any methods.
> >> Please see the example I referred you to.
> >>
> >> On Sat, Nov 20, 2010 at 3:06 PM, Stefano Bellasio <
> >> [email protected]
> >>> wrote:
> >>
> >>> Something like this? And then i have to package it and use instead of
> >>> Mahout-core..job right? Thanks again
> >>>
> >>>
> >>
>

Reply via email to