I am trying to add the fixed user similarities in the easiest possible way.

This is my starting code (a normal user-based algorithm based on Pearson
Correlation):

UserSimilarity similarity = new PearsonCorrelationSimilarity(dm);

UserNeighborhood neighborhood = new NearestNUserNeighborhood(15, 0.1,
similarity, dm);
GenericUserBasedRecommender = new GenericUserBasedRecommender(dm,
neighborhood, similarity);

I would say my (pseudo) code will be:

// UserSimilarity similarity = new PearsonCorrelationSimilarity(dm); // I
don't need this anymore

// UserNeighborhood neighborhood = new NearestNUserNeighborhood(15, 0.1,
similarity, dm); // I don't need this anymore

1) Read the similarities from a file ...

2) Build the neighborhood and similarity objects according to my matrix.
3) GenericUserBasedRecommender = new GenericUserBasedRecommender(dm,
neighborhood, similarity);

Part 2) is the most difficult, I thought the neighborhood object
represented, for each user, his neighbors but from my Eclipse inspection I
see there is much information and the neighbors seem not to be listed here,
but retrieved using getUserNeighborhood + userSimilarity ? I am getting
lost here, also because I am almost new to Java.

Is there anyone who can give me some hints about this task?

Thanks a lot in advance.

Eugenio


2015-02-13 18:29 GMT+01:00 Eugenio Tacchini <eugenio.tacch...@gmail.com>:

> Ok, thanks for your support.
>
> Eugenio
>
> 2015-02-11 11:54 GMT+01:00 Juanjo Ramos <jjar...@gmail.com>:
>
>> Yes. You approach sounds about right.
>>
>> As far as I know, you just cannot not pass a file to Mahout with user
>> similarities and it will create a UserSimilarity object as it can do with
>> the DataModel.
>>
>> When I have done something like that in the past, you need to build your
>> own thing of parsing the file and loading it into memory.
>>
>> On Wed, Feb 11, 2015 at 10:42 AM, Eugenio Tacchini <
>> eugenio.tacch...@gmail.com> wrote:
>>
>> > Yes, I know I can implement a custom user similarity but what I want to
>> do
>> > is passing to mahout fixed, pre-computed user similarities I have
>> already
>> > stored in a text file in the easiest way possible, since I am not a Java
>> > programmer.
>> >
>> > If there is no way to do it, I will implement CustomUserSimilarity just
>> by
>> > reading the text file, storing the file in memory and returning the
>> > corresponding similarity. I should do that making sure the read of the
>> text
>> > file is done just once, though.
>> >
>> > Eugenio
>> >
>> >
>> >
>> > 2015-02-11 11:28 GMT+01:00 Juanjo Ramos <jjar...@gmail.com>:
>> >
>> > > You can create your custom class with your similarity implementation.
>> All
>> > > you need is that class to implement the UserSimilarity interface and
>> use
>> > it
>> > > here
>> > > UserSimilarity similarity = new PearsonCorrelationSimilarity(dm);
>> > >
>> > > instead of the PearsonCorrelationSimilarity.
>> > >
>> > > UserSimilarity similarity = new CustomUserSimilarity(dm); //
>> > > CustomUserSimilarity
>> > > implements UserSimilarity
>> > >
>> > > If the implementation of that CustomUserSimilarity is in C, you may
>> want
>> > to
>> > > look into JNI (Java Native Interface) to call C code from Java.
>> > >
>> > > Best,
>> > > Juanjo.
>> > >
>> > > On Wed, Feb 11, 2015 at 9:48 AM, Eugenio Tacchini <
>> > > eugenio.tacch...@gmail.com> wrote:
>> > >
>> > > > Hello Pat and thanks for your reply,
>> > > > I know that when users >> items normally item-based works better
>> and I
>> > > > don't assume my similarity metric works better but I have, for
>> research
>> > > > purposes, to compare:
>> > > >
>> > > > - RMSE produced by a pearson correlation user-based algorithm VS
>> > > > - RMSE produced by a user-based algorithm where similarities are
>> > computed
>> > > > in a completely different and not standard way (algorithm
>> implemented
>> > in
>> > > C)
>> > > >
>> > > > so I am looking for a way to assign manually the user similarities;
>> the
>> > > > test will be performed just on a couple of datasets so it's fine if
>> I
>> > > have
>> > > > to hard-code the assignment.
>> > > >
>> > > > Eugenio
>> > > >
>> > > >
>> > > > 2015-02-10 23:58 GMT+01:00 Pat Ferrel <p...@occamsmachete.com>:
>> > > >
>> > > > > There are many algorithms in Mahout but not all are equal. Some
>> > > > > combinations never perform well even though they are described in
>> > > Mahout
>> > > > in
>> > > > > Action. The combination below is probably not the best.
>> > > > >
>> > > > > You seem to assume your user similarity metric is better than
>> > Mahout’s?
>> > > > Do
>> > > > > you have more users or items?
>> > > > >
>> > > > > If I were you I'd try user or item based recs in Mahout using LLR
>> > > > > similarity. It’s always performed best when I’ve compared. I say
>> this
>> > > > > because I know of no way to do what you ask without writing some
>> code
>> > > and
>> > > > > partly because I bet it will outperform.
>> > > > >
>> > > > > Also be aware that the only good way to compare completely
>> different
>> > > > > recommenders is A/B user testing.
>> > > > >
>> > > > > On Feb 10, 2015, at 3:39 AM, Eugenio Tacchini <
>> > > > eugenio.tacch...@gmail.com>
>> > > > > wrote:
>> > > > >
>> > > > > Hi all,
>> > > > > I am new to mahout but I work with recommender systems, I have
>> just
>> > > tried
>> > > > > to implement a simple user-based recommender:
>> > > > >
>> > > > > DataModel dm = new FileDataModel(new File("data/ratings.dat"));
>> > > > >
>> > > > > UserSimilarity similarity = new PearsonCorrelationSimilarity(dm);
>> > > > >
>> > > > > UserNeighborhood neighborhood = new
>> > > > > ThresholdUserNeighborhood(0.1,similarity, dm);
>> > > > >
>> > > > > UserBasedRecommender r = new GenericUserBasedRecommender(dm,
>> > > > neighborhood,
>> > > > > similarity);
>> > > > >
>> > > > > I would like to compare the results of this recommender with
>> another
>> > I
>> > > > > implemented using another technology. The only differences between
>> > the
>> > > > two
>> > > > > algorithms is the way I choose neighbors; since I am not very
>> fluent
>> > in
>> > > > > Java, instead of implementing the second algorithm in mahout, I
>> would
>> > > > like
>> > > > > to manually specify the neighbors for each user, is this possible?
>> > > Which
>> > > > is
>> > > > > the easiest way to provide an alternative user-user similarity
>> matrix
>> > > > > (computed using my algorithm)?
>> > > > >
>> > > > > Just to recap: I want to use GenericUserBasedRecommender but
>> > providing
>> > > an
>> > > > > alternative users similarity matrix, without reimplementing my
>> > > similarity
>> > > > > algorithm in Java. Basically if I could import the similarities
>> from
>> > a
>> > > > text
>> > > > > file it would be great, but other methods are fine as well.
>> > > > >
>> > > > > Thanks a lot in advance.
>> > > > >
>> > > > > Eugenio Tacchini
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>
>

Reply via email to