The Engine class for our reference is written as follows:
public class RecommendationEngine extends EngineFactory { @Override public BaseEngine<EmptyParams, Query, PredictedResult, Set<String>> apply() { return new Engine<>( DataSource.class, Preparator.class, Collections.<String, Class<? extends BaseAlgorithm<PreparedData, ?, Query, PredictedResult>>>singletonMap("algo", Algorithm.class), Serving.class ); } }
Key points to make a note from the preceding code are as follows:
An engine class extends from EngineFactory, which is provided by PredictionIO
The apply() interface method of the EngineFactory base class is overridden
The apply() method returns an instance of the engine class that has constructor parameters for the Datasource class, the Preparator class, the Singleton Map of Algorithm class, and the serving class
The preceding lines may be hard to interpret; class <? extends BaseAlgorithm<>>means that the type of the class is undetermined, but you are guaranteed that it extends BaseAlgorithm.
If you are familiar with Scala, the Scala code for the Engine would look as follows: