Try to build a recommendation system for Synced website.
First version is to realize a basic Item-Based Recommendation Engine to recommend several articles, which would be interested by an active user.
Add to Gemfile
gem 'recommendation', github: 'SyncedPSI/recommendation'
Then execute:
$ bundle
add `config/initializers/recommendation.rb
namespace = 'your:recommendation'
host = 'your_host'
redis_store = Redis.new(host: your_host, port: '6379', db: 5, namespace: 'recommendation')
Recommendation.configure do |config|
config.redis = redis_store
end
- "Users that viewed this article also viewed..." from
user_id--viewed-->article_id
pairs
input_data should look like this:
{
user1_id: [article1_id, article3_id, article5_id],
user2_id: [article3_id, article4_id, article5_id],
...
}
output should be like this:
article1_id: [article3_id, article4_id, ...]
Use redis to store the similarity matrix.
$ redis cli
> select 5 # select <db number>
> keys *
> HGET "recommendation:similarity" article_id
> KEYS recommendation*
redis_keys
- recommendation:similarity => 存储了所有文章的相似度
- recommendation:items => 存储了所有的文章阅读数量
- recommendation:item_pairs => 存储了每一对文章被同一个用户阅读过的数量
[1] George Karypis (2000) Evaluation of Item-Based Top-N Recommendation Algorithms (University of Minnesota, Department of Computer Science / Army HPC Research Center)