Thanks for the help.
I got the recommender based on items to work, but I cant seem to get
the recommender based on users to work.
I don't get any errors, I just don't get any results.
My call>
-----------------
WorkDataModel model = new WorkDataModel(accountDAO, arrangementDAO,
reviewDAO, arrangements);
UserSimilarity userSimilarity = new PearsonCorrelationSimilarity(model);
userSimilarity.setPreferenceInferrer(new AveragingPreferenceInferrer(model));
NearestNUserNeighborhood neighborhood = new NearestNUserNeighborhood
(3, userSimilarity, model);
GenericUserBasedRecommender recommender = new
GenericUserBasedRecommender(model, neighborhood, userSimilarity);
List<RecommendedItem> recommendations =
recommender.recommend(account.getId(), amount);
------------------
It looks like WorkDataModel returns everything correctly.
This is my test:
------------------
List<Arrangement> allReady = arrangementDAO.getAllReady();
Account ac1 = accountDAO.get(22L);
Account ac2 = accountDAO.get(21L);
Account ac3 = accountDAO.get(23L);
int i = 0;
Arrangement aSearch = null;
for (Arrangement a : allReady) {
if (i < 8) {
reviewDAO.save(new Review(a, ac1, 4F, Reviewtype.HUMAN));
}
if (i > 3) {
reviewDAO.save(new Review(a, ac2, 2F, Reviewtype.HUMAN));
}
if (i > 6 && i < 16) {
reviewDAO.save(new Review(a, ac3, 5F, Reviewtype.HUMAN));
}
if (i == 5) {
aSearch = a;
}
if (i > 15) {
break;
}
i++;
}
List<Arrangement> recommendations =
arrangementService.getRecommendations(ac1, allReady, 10);
-------------------
I'm not really sure what I am sending in there, I'm just trying to mix
it up a bit :-)
I have tried to get recommendations from for all three of the accounts
(users), but I don't get anything.
Do I need more preferences, or is something else wrong?? The
preferences are not overlapping, so shouldn't I get some kind of
result back?
Thanks!
Johan
On Thu, Nov 26, 2009 at 12:02 PM, Sean Owen <[email protected]> wrote:
> Yes everything looks fine here, but with one key issue.
> It seems you are trying to recommender "users" to "items" in the
> second case. That is not what an item-based recommender does -- it
> still recommenders items to users.
>
> To do what you want, you need to transpose user and item IDs in your
> DataModel, then use any algorithm you like. It's a two-line change to
> the line where you make a GenericPreference. Maybe create a flag in
> the constructor that controls this so you can reuse the model in both
> cases.
>
> It does mean you need a separate model, yes.
>
> PS I think your model-building will use a lot of memory at peak --
> that map of Collection<Preference> will be a lot bigger than the final
> data set. You can instead build PreferenceArray directly, note.
>
> On Thu, Nov 26, 2009 at 9:38 AM, Johan Fredholm
> <[email protected]> wrote:
>> Hi,
>> I have been trying to configure Mahout for using hibernate. I haven't
>> been able to find any examples of such a configuration. Its probably
>> the wrong way to do it but I cant even get this simple model to work.
>> It would be great if you could tell me what I'm doing wrong here, and
>> maybe some pointers on how it should be done.
>>
>