app/models/user.rb
# Feature vector to compare with other users
Feature vector to compare with other users
Feature vector to compare with other users
def feature_vector
    if @feature_vector.nil?
      @feature_vector = clicks_90.group(:notebook_id).count
      @feature_vector.each {|id, count| @feature_vector[id] = Math.log(count + 1)}
      stars.each do |star|
        @feature_vector[star.id] ||= 0
        @feature_vector[star.id] += 1
      end
    end
    @feature_vector
  end
def feature_vector if @feature_vector . nil? @feature_vector = clicks_90 . group ( :notebook_id ) . count @feature_vector . each { | id , count | @feature_vector [ id ] = Math . log ( count + 1 ) } stars . each do | star | @feature_vector [ star . id ] ||= 0 @feature_vector [ star . id ] += 1 end end @feature_vector end
Feature vector to compare with other users
Feature vector to compare with other users