基于 ruby/redis 的推荐引擎:recommendify

jopen 10年前

recommendify 是基于 ruby/redis 的推荐引擎  (协同过滤)。

# Our similarity matrix, we calculate the similarity via co-concurrence   # of products in "orders" using the jaccard similarity measure.  class MyRecommender < Recommendify::Base      # store only the top fifty neighbors per item    max_neighbors 50      # define an input data set "order_items". we'll add "order_id->product_id"    # pairs to this input and use the jaccard coefficient to retrieve a     # "customers that ordered item i1 also ordered item i2" statement and apply    # the result to the item<->item similarity matrix with a weight of 5.0    input_matrix :order_items,        # :native => true,      :similarity_func => :jaccard,          :weight => 5.0    end    recommender = MyRecommender.new    # add `order_id->product_id` interactions to the order_item_sim input  # you can add data incrementally and call RecommendedItem.process! to update  # the similarity matrix at any time.  recommender.order_items.add_set("order1", ["product23", "product65", "productm23"])  recommender.order_items.add_set("order2", ["product14", "product23"])    # Calculate all elements of the similarity matrix  recommender.process!    # ...or calculate a specific row of the similarity matrix (a specific item)  # use this to avoid re-processing the whole matrix after incremental updates  recommender.process_item!("product65")    # retrieve similar products to "product23"  recommender.for("item23")     => [ <Recommendify::Neighbor item_id:"product65" similarity:0.23>, (...) ]    # remove "product23" from the similarity matrix and the input matrices. you should   # do this if your items 'expire', since it will speed up the calculation  recommender.delete_item!("product23") 

项目主页:http://www.open-open.com/lib/view/home/1391952339004