GithubHelp home page GithubHelp logo

cf-project's Introduction

CF-project

基于协同过滤算法的项目(未完成)
该项目在之前的纷享app项目的基础之前上进行改进,去除文章部分模块,添加推荐模块
该算法分别使用基于用户、基于物品两种方式进行实现(现只展示两种方法的工具类)

推荐模块:

数据库方面

  • 添加用户行为表:用于记录用户对商品的商品的点击、是否收藏、分享次数等,用于计算用户相似度、物品相似度
  • 添加用户相似度表:用于记录已经计算好的用户相似度,以提升系统性能
  • 添加物品相似度表:用于记录已经计算好的物品相似度,以提升系统性能

后台代码实现

基于用户的协同过滤

  • 使用Map数据结构,将用户与其对应的行为数据构造成矩阵,进行相似度计算(相似度计算为余弦相似度公式) image

  • 设向量 A = (A1,A2,A3,...,An), B = (B1,B2,B3,...,Bn),推广到多维,公式为:
    image
    其中的 A1,A2,A3...就可以理解为该用户对不同的商品的点击量。(这里将使用数据归一化,将其转化为五分值,好进行比较)

基于物品的协同过滤

  • 基于物品的协同过滤算法,主要是根据这个公式
    image
    这里N(u)表示用户u喜欢的物品列表,S(j,k)表示和物品j最为相似的k个物品,Wji表示物品j和物品i的相似度,rui表示用户u对物品i的喜欢程度所以,只要得到Wji和rui就可以得到推荐列表
  • 物品的相似矩阵,这里采用的公式是
    image
    其中分母 |N(i)| 是喜欢物品 i 的用户数,分母 |N(j)| 是喜欢物品 j的用户数,而分子 |N(i) ∩N(j)| 是同时喜欢物品 i 和物品 j 的用户数 a代表权重,这里取a=0.5

cf-project's People

Contributors

myshelter-c avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.