嗨,马赫特社区在苏!
我有几个关于加速推荐计算的问题。在我的服务器上,我没有Hadoop就安装了Mahout。另外,jRuby也用于推荐脚本。在数据库中,我有3k用户和100 k项(连接表中的270 k项)。因此,当用户请求推荐时,简单的脚本开始工作:
首先,它使用如下所示的PGPoolingDataSource建立db连接:
connection = org.postgresql.ds.PGPoolingDataSource.new()
connection.setDataSourceName("db_name");
connection.setServerName("localhost")
connection.setPortNumber(5432)
connection.setDatabaseName("db_name")
connection.setUser("mahout")
connection.setPassword("password")
connection.setMaxConnections(100)
connection我收到警告:
WARNING: You are not using ConnectionPoolDataSource. Make sure your DataSource pools connections to the database itself, or database performance will be severely reduced.有什么办法解决这个问题吗?
在此之后,我提出以下建议:
model = PostgreSQLJDBCDataModel.new(
connection,
'stars',
'user_id',
'repo_id',
'preference',
'created_at'
)
similarity = TanimotoCoefficientSimilarity.new(model)
neighborhood = NearestNUserNeighborhood.new(5, similarity, model)
recommender = GenericBooleanPrefUserBasedRecommender.new(model, neighborhood, similarity)
recommendations = recommender.recommend user_id, 30目前,为一个用户生成推荐大约需要5-10秒。问题是如何更快地提出建议(200 is将很好)?
发布于 2012-10-22 22:15:34
如果您知道您正在使用池数据源,则可以忽略该警告。这意味着该实现没有实现池实现的通常接口,即ConnectionPoolDataSource。
如果试图直接从数据库上运行,就永远不会使它运行得很快。数据访问太多了。将JDBCDataModel封装在ReloadFromJDBCDataModel中,它将被缓存在内存中,这应该可以更快地工作100倍。
https://stackoverflow.com/questions/13018982
复制相似问题