以下建议使用了非常大的客户数据库(数百万个条目),并且加载文件的时间太长。
public static void main(String[] args) throws Exception {
MysqlDataSource dataSource = new MysqlDataSource ();
dataSource.setServerName("localhost");
dataSource.setUser("root");
dataSource.setPassword("");
dataSource.setDatabaseName("db_recommend");
ReloadFromJDBCDataModel model = new ReloadFromJDBCDataModel(new MySQLBooleanPrefJDBCDataModel(dataSource, "table_recommend", "cust_id","item_id" , null));
UserSimilarity similarity = new LogLikelihoodSimilarity(model);
UserNeighborhood neighborhood = new NearestNUserNeighborhood(2, similarity, model);
Recommender recommender = new GenericBooleanPrefUserBasedRecommender(model, neighborhood, similarity);
Recommender cachingrecommender = new CachingRecommender(recommender);
cachingrecommender.refresh(null);
List<RecommendedItem>recommendations = cachingrecommender.recommend(10001, 3);
for (RecommendedItem recommendation : recommendations) {
System.out.println(recommendation);
}
}
问题在于产生推荐大约需要两分钟。如果部署在Web应用程序中,这将非常慢。关于如何使其运行更快的任何建议?