Building recommender system - UCM-GAIA/RecoLibry-Core GitHub Wiki
In this section, we explain how to build an instance of the recommender system defined using one of the methods described in the recommender system configuration section. To separate it from the configuration, we recommend the creation of a new class. This class will be the main class to execute the recommender system. For example, we will create a new class called TestRecSys
.
In this class, we will create a static method to build the recommender system. We call this method getRecommenderSystem()
. It will return a recommender system based on the defined configuration. If the configuration is implemented in a class, we will use the method makeRecommender()
from RecommenderSystemFactory
class to get an instance of our recommender system:
public static RecommenderSystem getRecommenderSystem() {
//Object with recommender system configuration
RecSysConfiguration configuration = new TestConfiguration();
//Create a new instance of recommender system
RecommenderSystemFactory factory = new RecommenderSystemFactory();
factory.makeRecommender(configuration);
// Return recommender system
return factory.getRecommender();
}
In case of defining a configuration file, we call the function makeRecommenderSystemByJson()
from RecommenderSystemFactory
with the file configuration path:
public RecommenderSystem static getRecommenderSystem() {
//Create a new instance of recommender system
RecommenderSystemFactory factory = new RecommenderSystemFactory();
factory.makeRecommenderByJson("./configurations/configuration.json");
// Return recommender system
return factory.getRecommender();
}
After executing this function we will obtain an instance of our recommender system. Next, we can continue with the execution of the recommender system.