In Main Concepts and Getting started (2) - How does mainGenreLMS get it's data? we already saw examples of the way feedback processors, profile models and predictors work together to calculate a prediction about an item. In this section the coherence between predictors, ratable items, profile models and feedback processors is described in more detail, including some example snippets from the Duine configuration files.
Predictors will need access to data. The nature of the specific predictor algorithm determines what kind of data is needed. In almost every case a predictor needs access to profile data. Some predictors need access to information in the ratable item as well (content dependent predictors). A feedback processor needs access to a profile model, and in some cases to a predictor and/or ratable item as well. The dependency relations between predictors, content items, profile models and feedback processors are shown below.
The arrows in this figure represent dependencies. The dependencies are explained below.
A predictor needs access to profile data to calculate its predictions. This is represented by dependency 1. Some predictors need access to information in the ratable item as well (content dependent predictors). This is represented by dependency 2.
dependency 1
A specific kind of predictor is "wired" to a specific kind of profile model by means of configuration, as shown in the following configuration snippet
<!-- see spring-predictors.xml in demo application --> <bean id="userAverage" class="org.duineframework.recommender.predictor.UserAverage"> <description>Calculates the predictions based on the user's average rating.</description> <property name="name" value="userAverage" /> <property name="ratingModel" ref="ratingModel"/> <property name="certaintyReductionFactor" value="50"/> </bean> <!-- see spring-profiles.xml in demo application --> <bean id="ratingModel" class="org.duineframework.recommender.profile.rating.RatingModel"> ...... </bean>
dependency 2
This dependency only exists for content dependent predictors. An example is the InformationFiltering predictor. This predictor needs to get access to term-weight data that is extracted from the content item metadata. Because we want the predictor to be reusable for all types of content items the predictor can not access content items directly. Instead the algorithm uses a socalled IRatable2TermWeightAdapter. Applications can wire an adapter into the predictor that adapts the interface of the application specific content item to the interface that the InformationFiltering predictor expects. A configuration snippet is shown below.
<!-- see spring-predictors.xml in demo application --> <bean id="informationFiltering" class="org.duineframework.recommender.predictor.InformationFiltering"> <description>Uses term weight maps for its predictions.</description> <property name="name" value="informationFiltering"/> <property name="interestModel" ref="infoFilterInterestModel"/> <property name="ratable2TermWeightAdapter" ref="ratable2TermWeightAdapter"/> </bean> <bean id="ratable2TermWeightAdapter" class="org.duineframework.movielens.Movie2TermWeightAdapter"> </bean>
The code below shows the Movie2TermWeightAdapter code
public class Movie2TermWeightAdapter implements IRatable2TermWeightAdapter { public Map<String, Double> getTermWeightMap(IRatableItem item) { if (!(item instanceof Movie)) { return new HashMap<String, Double>(); } Movie movie = (Movie) item; return movie.getTermWeightMap(); } }
A feedback processor processes feedback (dependency 3 ) and updates the profile model (dependency 5 ). Some feedback processors need access to the ratable item for processing purposes (dependency 4 ). There are also feedback processors that need access to a predictor (dependency 6 ) as part of their feedback processing algorithm.
The configuration snippet below provides an example of a feedback processor that implements all mentioned dependencies. It is a feedback processor that slightly modifies (as part of the learning process) the interests of a user based on the term weights of a rated content item. The dependency numbers mentioned here are added in the description elements as a reference.
<!-- see spring-profiles.xml in demo application --> <bean id="infoFilterInterestModel.LMSfeedbackProcessor" class="org.duineframework.recommender.profile.interest.InformationFilteringFeedbackProcessor"> <property name="id" value="infoFilterInterestModel.feedbackProcessor"/> <property name="interestModel" ref="infoFilterInterestModel"> <description>dependency 5</description> </property> .... <property name="predictor" ref="informationFiltering"> <description>dependency 6</description> </property> <property name="ratable2TermWeightAdapter" ref="ratable2TermWeightAdapter"> <description>dependency 4</description> </property> </bean>