org.lenskit

## Class LenskitRecommender

• ### 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)
Deprecated.
static LenskitRecommender build(LenskitConfiguration config, DataAccessObject dao)
Build a recommender from a configuration.
void close()
Close the recommender.
<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.
ItemBasedItemRecommender getItemBasedItemRecommender()
Get the recommender’s item-based item recommender.
ItemBasedItemScorer getItemBasedItemScorer()
Get the recommender’s item-based 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.

Parameters:
T - The type of component to get.
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.

Parameters:
T - The type of component to get.
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.

Parameters:
T - The type of component to get.
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 the configured recommender, 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.
• #### getItemBasedItemScorer

@Nullable
public ItemBasedItemScorer getItemBasedItemScorer()
Description copied from interface: Recommender

Get the recommender’s item-based item scorer.

Specified by:
getItemBasedItemScorer in interface Recommender
Returns:
The item-based item scorer for the configured recommender, or null if basket-based scoring is not supported.
• #### getItemBasedItemRecommender

@Nullable
public ItemBasedItemRecommender getItemBasedItemRecommender()
Description copied from interface: Recommender

Get the recommender’s item-based item recommender.

Specified by:
getItemBasedItemRecommender in interface Recommender
Returns:
The item-based item recommender for the configured recommender, or null if basket-based scoring is not supported.
• #### close

public void close()
Description copied from interface: Recommender

Close the recommender. This closes underlying resources such as database collections. Components retrieved from the recommender must be used once the recommender is closed. Components capable of explicitly detecting use-after-close will indicate such invalid use by throwing IllegalStateException, although they may fail with other exceptions. The results of using a component after its recommender has been closed are formally undefined.

Specified by:
close in interface AutoCloseable
Specified by:
close in interface Recommender
• #### build

@Deprecated
public static LenskitRecommender build(LenskitConfiguration config)
throws RecommenderBuildException
Deprecated.

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
• #### build

public static LenskitRecommender build(LenskitConfiguration config,
DataAccessObject dao)
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.
dao - The data access object.
Returns:
The recommender.
Throws:
RecommenderBuildException - If there is an error building the recommender.
Since:
2.0
Skip navigation links