lib/disco/recommender.rb in disco-0.4.2 vs lib/disco/recommender.rb in disco-0.5.0

- old
+ new

@@ -62,12 +62,12 @@ @min_rating = nil @max_rating = nil end if @top_items - @item_count = [0] * @item_map.size - @item_sum = [0.0] * @item_map.size + @item_count = Array.new(@item_map.size, 0) + @item_sum = Array.new(@item_map.size, 0.0) train_set.each do |v| i = @item_map[v[:item_id]] @item_count[i] += 1 @item_sum[i] += (@implicit ? 1 : v[:rating]) end @@ -426,64 +426,9 @@ new_names = dataset.vectors.to_a.map { |k| [k, k.to_sym] }.to_h dataset.rename_vectors!(new_names) dataset.to_a[0] else dataset - end - end - - def marshal_dump - warn "[disco] Marshal serialization is deprecated - use JSON instead" - - obj = { - implicit: @implicit, - user_map: @user_map, - item_map: @item_map, - rated: @rated, - global_mean: @global_mean, - user_factors: @user_factors, - item_factors: @item_factors, - factors: @factors, - epochs: @epochs, - verbose: @verbose - } - - unless @implicit - obj[:min_rating] = @min_rating - obj[:max_rating] = @max_rating - end - - if @top_items - obj[:item_count] = @item_count - obj[:item_sum] = @item_sum - end - - obj - end - - def marshal_load(obj) - warn "[disco] Marshal serialization is deprecated - use JSON instead" - - @implicit = obj[:implicit] - @user_map = obj[:user_map] - @item_map = obj[:item_map] - @rated = obj[:rated] - @global_mean = obj[:global_mean] - @user_factors = obj[:user_factors] - @item_factors = obj[:item_factors] - @factors = obj[:factors] - @epochs = obj[:epochs] - @verbose = obj[:verbose] - - unless @implicit - @min_rating = obj[:min_rating] - @max_rating = obj[:max_rating] - end - - @top_items = obj.key?(:item_count) - if @top_items - @item_count = obj[:item_count] - @item_sum = obj[:item_sum] end end def json_load(obj) require "base64"