public final class LenskitRecommenderEngine extends Object implements RecommenderEngine
LenskitConfiguration
to set up actual recommenders, and can build
multiple recommenders from the same model.
If you just want to quick create a recommender for evaluation or testing,
consider using LenskitRecommender.build(LenskitConfiguration)
.
LenskitConfiguration
,
LenskitRecommender
Modifier and Type | Method and Description |
---|---|
static LenskitRecommenderEngine |
build(LenskitConfiguration config)
Build a LensKit recommender engine from a configuration.
|
LenskitRecommender |
createRecommender()
Create a new recommender..
|
LenskitRecommender |
createRecommender(LenskitConfiguration config)
Construct a recommender with some additional configuration.
|
<T> T |
getComponent(Class<T> type)
Get the component of a particular type, if one is already instantiated.
|
DAGNode<Component,Dependency> |
getGraph()
Get the dependency graph of the recommender engine.
|
boolean |
isInstantiable()
Query whether this engine is instantiable.
|
static LenskitRecommenderEngine |
load(File file)
Create a new LenskitRecommenderEngine by reading a previously serialized engine from the
given file.
|
static LenskitRecommenderEngine |
load(File file,
ClassLoader loader)
Deprecated.
Use
LenskitRecommenderEngineLoader for sophisticated loading. |
static LenskitRecommenderEngine |
load(InputStream input)
Create a new LenskitRecommenderEngine by reading a previously serialized engine from the
given input stream.
|
static LenskitRecommenderEngine |
load(InputStream input,
ClassLoader loader)
Deprecated.
Use
LenskitRecommenderEngineLoader for sophisticated loading. |
static LenskitRecommenderEngineBuilder |
newBuilder()
Create a new recommender engine builder.
|
static LenskitRecommenderEngineLoader |
newLoader()
Create a new recommender engine loader.
|
void |
write(File file)
Write the state of this LenskitRecommenderEngine to the given file so
that it can be recreated later using another DAOFactory.
|
void |
write(File file,
CompressionMode compressed)
Write the state of this LenskitRecommenderEngine to the given file so
that it can be recreated later using another DAOFactory.
|
void |
write(OutputStream stream)
Write the state of this LenskitRecommenderEngine to the given stream so
that it can be recreated later using another DAOFactory.
|
public static LenskitRecommenderEngine load(File file) throws IOException, RecommenderConfigurationException
write(OutputStream)
.
Classes will be loaded using a default class loader.file
- The file from which to load the engine.IOException
- If there is an error reading from the file.RecommenderConfigurationException
- If the configuration cannot be used.@Deprecated public static LenskitRecommenderEngine load(File file, ClassLoader loader) throws IOException, RecommenderConfigurationException
LenskitRecommenderEngineLoader
for sophisticated loading.write(OutputStream)
.file
- The file from which to load the engine.loader
- The class loader to load from (null
to use a default class loader).IOException
- If there is an error reading from the file.RecommenderConfigurationException
- If the configuration cannot be used.public static LenskitRecommenderEngine load(InputStream input) throws IOException, RecommenderConfigurationException
write(OutputStream)
. Classes will be loaded using a default
class loader.input
- The stream from which to load the engine.IOException
- If there is an error reading from the file.RecommenderConfigurationException
- If the configuration cannot be used.@Deprecated public static LenskitRecommenderEngine load(InputStream input, ClassLoader loader) throws IOException, RecommenderConfigurationException
LenskitRecommenderEngineLoader
for sophisticated loading.write(OutputStream)
.input
- The stream from which to load the engine.loader
- The class loader to load from (null
to use a default class loader).IOException
- If there is an error reading from the file.RecommenderConfigurationException
- If the configuration cannot be used.public void write(@Nonnull File file) throws IOException
file
- The file to write the rec engine to.IOException
- if there is an error serializing the engine.write(java.io.OutputStream)
public void write(@Nonnull File file, CompressionMode compressed) throws IOException
file
- The file to write the rec engine to.compressed
- Whether to compress the output file.IOException
- if there is an error serializing the engine.write(java.io.OutputStream)
public void write(@Nonnull @WillClose OutputStream stream) throws IOException
stream
- The file to write the rec engine to.IOException
- if there is an error serializing the engine.load(InputStream)
public LenskitRecommender createRecommender()
RecommenderEngine
createRecommender
in interface RecommenderEngine
public LenskitRecommender createRecommender(LenskitConfiguration config) throws RecommenderConfigurationException
config
- The configuration to adjust the recommender.RecommenderConfigurationException
- if there is an error configuring the recommender.public boolean isInstantiable()
true
if the recommender is instantiable.@Nonnull public DAGNode<Component,Dependency> getGraph()
@Nullable public <T> T getComponent(Class<T> type)
T
- The required component type.type
- The required component type.null
if no instance can be retreived (either because no such
component is configured, or it is not yet instantiated).public static LenskitRecommenderEngine build(LenskitConfiguration config) throws RecommenderBuildException
config
- The configuration.RecommenderBuildException
public static LenskitRecommenderEngineBuilder newBuilder()
public static LenskitRecommenderEngineLoader newLoader()