org.grouplens.lenskit.core

Class LenskitRecommender

• All Implemented Interfaces:
Recommender

public class LenskitRecommender
extends Object
implements Recommender
Recommender implementation built on LensKit containers. Recommenders built with LenskitRecommenderEngine will produce this type of recommender.

The Recommender interface will meet most needs, so most users can ignore this class. However, if you need to inspect internal components of a recommender (e.g. extract the item-item similarity matrix), this class and its get(Class) method can be useful.

Compatibility
Public
• Constructor Summary

Constructors
Constructor and Description
LenskitRecommender(DAGNode<Component,Dependency> graph)
Create a new LensKit recommender.
• Method Summary

All Methods
Modifier and Type Method and Description
static LenskitRecommender build(LenskitConfiguration config)
Build a recommender from a configuration.
<T> T get(Annotation qual, Class<T> cls)
Get a particular qualified component from the recommender session.
<T> T get(Class<? extends Annotation> qual, Class<T> cls)
Get a particular qualified component from the recommender session.
<T> T get(Class<T> cls)
Get a particular component from the recommender session.
GlobalItemRecommender getGlobalItemRecommender()
Get the recommender's global item recommender.
GlobalItemScorer getGlobalItemScorer()
Get the recommender's global item scorer.
ItemRecommender getItemRecommender()
Get the recommender's item recommender.
ItemScorer getItemScorer()
Get the recommender's item scorer.
RatingPredictor getRatingPredictor()
Get the recommender's rating scorer.
• Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• Method Detail

• get

public <T> T get(Class<T> cls)
Get a particular component from the recommender session. Generally you want to use one of the type-specific getters; this method only exists for specialized applications which need deep access to the recommender components.
Type Parameters:
T - The type of component to get.
Parameters:
cls - The component class to get.
Returns:
The instance of the specified component.
• get

public <T> T get(Class<? extends Annotation> qual,
Class<T> cls)
Get a particular qualified component from the recommender session. Generally you want to use one of the type-specific getters; this method only exists for specialized applications which need deep access to the recommender components.
Type Parameters:
T - The type of component to get.
Parameters:
qual - The qualifying annotation of the component class.
cls - The component class to get.
Returns:
The instance of the specified component.
• get

public <T> T get(Annotation qual,
Class<T> cls)
Get a particular qualified component from the recommender session. Generally you want to use one of the type-specific getters; this method only exists for specialized applications which need deep access to the recommender components.
Type Parameters:
T - The type of component to get.
Parameters:
qual - The qualifying annotation of the component class.
cls - The component class to get.
Returns:
The instance of the specified component.
• getItemScorer

public ItemScorer getItemScorer()
Description copied from interface: Recommender
Get the recommender's item scorer.
Specified by:
getItemScorer in interface Recommender
Returns:
The item scorer for this recommender configuration, or null if item scoring is not supported.
• getGlobalItemScorer

public GlobalItemScorer getGlobalItemScorer()
Description copied from interface: Recommender
Get the recommender's global item scorer.
Specified by:
getGlobalItemScorer in interface Recommender
Returns:
The global item scorer for this recommender configuration, or null if item scoring is not supported.
• getRatingPredictor

public RatingPredictor getRatingPredictor()
Description copied from interface: Recommender
Get the recommender's rating scorer.
Specified by:
getRatingPredictor in interface Recommender
Returns:
The rating predictor for this recommender configuration, or null if rating prediction is not supported.
• getItemRecommender

public ItemRecommender getItemRecommender()
Description copied from interface: Recommender
Get the recommender's item recommender.
Specified by:
getItemRecommender in interface Recommender
Returns:
The item recommender for this recommender configuration, or null if item recommendation is not supported.
• getGlobalItemRecommender

public GlobalItemRecommender getGlobalItemRecommender()
Description copied from interface: Recommender
Get the recommender's global item recommender.
Specified by:
getGlobalItemRecommender in interface Recommender
Returns:
The item recommender for this recommender configuration, or null if item recommendation is not supported.
• build

public static LenskitRecommender build(LenskitConfiguration config)
throws RecommenderBuildException
Build a recommender from a configuration. The recommender is immediately usable. This is mostly useful for evaluations and test programs; more sophisticated applications that need to build multiple recommenders from the same model should use a recommender engine.
Parameters:
config - The configuration.
Returns:
The recommender.
Throws:
RecommenderBuildException - If there is an error building the recommender.
Since:
2.0