Recommendation
From LiquidPubWiki
Contents |
General
The recommender is implemented using Apache Mahout. It uses the following classes:
- GenericBooleanPrefUserBasedRecommender - works for our case when there are no ratings.
- TanimotoCoefficientSimilarity - used for the boolean recommender.
- NearestNUserNeighborhood with N=6 and using 100% of the dataset.
These settings are set in the LiquidJournalMahoutRecommender.java class. This class implements the Mahout's Taste recommender.
Although Mahout documentation states that it requires Hadoop, the algorithms that I used can be run without Hadoop installed.
Links to Apache Mahout documentation
- http://lucene.apache.org/mahout/taste.html#Recommender
- http://cwiki.apache.org/MAHOUT/buildingmahout.html
- http://lucene.apache.org/mahout/javadoc/core/index.html
Changes to the Mahout files
I've modified the method public double userSimilarity(long userID1, long userID2) in AbstractSimilarity.java in package org.apache.mahout.cf.taste.impl.similarity. Added these two lines after the declaration of xPrefs and yPrefs.
xPrefs.sortByItem(); yPrefs.sortByItem();
I've compiled it using maven and the jar file is used in the other projects.
Path to the jar file: https://dev.liquidpub.org/svn/liquidpub/recommendation
Recommender for Liquid Journals
Two algorithms are implemented:
- User-based collaborative filtering (user=liquidjournal)
The recommender takes as input a liquidjournal id and returns n (default 3) contribution ids as recommendation. The algorithm first finds other liquid journals that are most similar (share the same contributions) to the target liquid journal which we want to receive recommendations for. The contributions that are popular among the similar liquid journals and that are not already in the target liquid journal are recommended. It is possible that no recommendation is returned. This happens when there the algorithm cannot find enough liquidjournals that are similar to it.
- Top contributions that appear in the most liquid journals
The algorithm getTopNContributions is implemented in the JournalItemDao.java
File structure
The following files are added to the liquidjournals project:
- package org.liquidjournals
- LiquidJournalMahoutRecommender.java
- package org.liquidjournals.service
- RecommenderManager.java (interface)
- package org.liquidjournals.service.impl
- RecommenderManagerImpl.java
- package org.liquidjournals.web
- LiquidJournalController.java added the method public HttpHeaders recommendation()
Added mahout jar in the project's WEB-INF/lib folder
Modified pom.xml by adding a new dependency
<dependency> <groupId>org.apache.mahout</groupId> <artifactId>mahout-core</artifactId> <version>0.2-SNAPSHOT</version> <scope>system</scope> <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/mahout-core-0.2-SNAPSHOT.jar</systemPath> </dependency>
Usage
The REST call is http://demo.liquidpub.org/liquidjournals/liquid-journal/[journalId]/recommendation.xml?algorithm=[similarity/popularity&numItem=[N]
- similarity = cf based algorithm
- popularity = top contributions
Widget examples based on Liquid Journal
- Similar contributions
This widget displays recommendation of contributions to be added to a specific LJ. It calls the similarity algorithm.
In the workspace.html example, click the one of the liquid journals on the left and the recommendations of that LJ will be displayed on the right.
[BUG] For test journals (the name of the LJs are "test journal" in the system), no recommendation can be found but the list in the widget is not updated.
Developed using ExtJS.
File: recommender.js
Deployed example: http://demo.liquidpub.org/liquidjournals/web/rec/workspace.html
- Top contributions
This widget displays the top contributions that appears in Liquid Journals. It calls the popularity algorithm.
Developed using Netvibes.
File: recommender-widget.html
Deployed example: http://yggdrasil.science.unitn.it:8080/demo/services
