public class LenskitRecommender extends java.lang.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.
Constructor and Description |
---|
LenskitRecommender(DAGNode<Component,Dependency> graph)
Create a new LensKit recommender.
|
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(java.lang.annotation.Annotation qual,
java.lang.Class<T> cls)
Get a particular qualified component from the recommender session.
|
<T> T |
get(java.lang.Class<? extends java.lang.annotation.Annotation> qual,
java.lang.Class<T> cls)
Get a particular qualified component from the recommender session.
|
<T> T |
get(java.lang.Class<T> cls)
Get a particular component from the recommender session.
|
DataAccessObject |
getDataAccessObject()
Get the data access object from this recommender.
|
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.
|
public LenskitRecommender(DAGNode<Component,Dependency> graph)
Create a new LensKit recommender. Most code does not need to call this constructor, but rather use build(LenskitConfiguration)
or a LenskitRecommenderEngine
.
graph
- This recommender’s configuration graph.@Nullable public <T> T get(java.lang.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.
T
- The type of component to get.cls
- The component class to get.@Nullable public <T> T get(java.lang.Class<? extends java.lang.annotation.Annotation> qual, java.lang.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.
T
- The type of component to get.qual
- The qualifying annotation of the component class.cls
- The component class to get.@Nullable public <T> T get(java.lang.annotation.Annotation qual, java.lang.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.
T
- The type of component to get.qual
- The qualifying annotation of the component class.cls
- The component class to get.public ItemScorer getItemScorer()
Recommender
Get the recommender’s item scorer.
getItemScorer
in interface Recommender
null
if item scoring is not supported.public RatingPredictor getRatingPredictor()
Recommender
Get the recommender’s rating scorer.
getRatingPredictor
in interface Recommender
null
if rating prediction is not supported.public ItemRecommender getItemRecommender()
Recommender
Get the recommender’s item recommender.
getItemRecommender
in interface Recommender
null
if item recommendation is not supported.@Nullable public ItemBasedItemScorer getItemBasedItemScorer()
Recommender
Get the recommender’s item-based item scorer.
getItemBasedItemScorer
in interface Recommender
null
if basket-based scoring is not supported.@Nullable public ItemBasedItemRecommender getItemBasedItemRecommender()
Recommender
Get the recommender’s item-based item recommender.
getItemBasedItemRecommender
in interface Recommender
null
if basket-based scoring is not supported.@Nonnull public DataAccessObject getDataAccessObject()
Get the data access object from this recommender.
public void close()
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.
close
in interface java.lang.AutoCloseable
close
in interface Recommender
@Deprecated public static LenskitRecommender build(LenskitConfiguration config) throws RecommenderBuildException
build(LenskitConfiguration, DataAccessObject)
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.
config
- The configuration.RecommenderBuildException
- If there is an error building the recommender.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.
config
- The configuration.dao
- The data access object.RecommenderBuildException
- If there is an error building the recommender.