Python movie recommendation system crawler Django framework collaborative filtering recommendation algorithm data analysis vue framework computer graduation project

1. Project introduction:

This recommendation system adopts a layered model design idea. The first layer is the front-end page model design, focusing on the display effect of the page. The main programming language is JavaScript, and the front-end mainstream framework bootstrap.

The second layer is the design of the back-end model. The programming language is python, which is easy to understand, and Django is used as the back-end framework for development. This framework is the preferred framework for python web system development, and it is easy to use.

The third layer is the logic of algorithm design and implementation, which is realized by collaborative filtering algorithm, and the fourth layer is the design of database table, which uses SQLite database.

The functional modules on the web side of this system mainly realize functions such as movie display, movie classification display, popular movie sorting display, favorite movie sorting display, time sorting display, rating sorting display, algorithm recommendation, movie search, movie information management, etc., and perform database management Detailed design, complete the various functions in the design stage, and conduct functional tests on this system. Finally, the system performs related practical application operations. Through the use of the system, users enter the movie recommendation system. The labeling behavior recommends movies that the user is interested in, with an accuracy rate of about 75%. Users can view information, watch movies, and rate movies. The system basically completes the expected basic functions.

2. Technical introduction:

Frontend: bootstrap3 + js+ jquery

Backend: django 2.2.1 + django--rest-framework (MVC framework)

Database: MySQL/sqlite3

Algorithm: Collaborative filtering recommendation algorithm

Douban dataset

Use crawlers to grab the movie information of the Douban movie website, with pictures

id,title ,image-link ,country ,years ,director-description,leader,star ,

description,alltags,imdb,language,time-length

Number of Movies: 3000

3. Function introduction:

Movie display, tag classification, detailed introduction, movie search

User login, registration, modification information

User ratings, favorites, and comments on movies

Collaborative filtering recommendation algorithm based on user and item

background management system

4. Algorithm Introduction

1、冷启动问题解决

推荐值: 相似度*评分 根据用户点赞过得商品来寻找相似度推荐。计算每个点赞过的物品和所有未点赞物品之间的得分。得分=相似度*打分值分越高表示越相似。 然后返回结果。

2、项目文件介绍

media/ 静态文件存放处,图片

movie/ Django的默认app,负责设置的配置还有url路由,部署等功能

static/ css文件和js文件的存放处

user/ 主app,程序的所有代码基本都在这下面 user/migrations为自动生成的数据库迁移文件 user/templates为前端页面模板文件, user/admins.py 为管理员后台代码 user/forms.py为前端表单代码 user/models.py为数据库orm模型 user/serializers.py为restful文件,不用管。 user/urls为路由注册文件。 user/views为负责处理前端请求和与后端数据库交互的模块,也就是controller模块。

cache_keys.py为缓存的key值名称存放文件,不用管。

db.sqlite3数据库文件

douban_crawler.py 豆瓣爬虫文件

manage.py 运行的主程序,从这里启动

Populate movies script.py 填充电影数据到数据库中

Populate user rate.py 随机生成用户评分

recommend_movies.py为推荐算法的部分

model: recommend模型存放的位置

3、后台管理

通过创建管理员进入后台,已经自带管理员用户名和密码均为admins。

同时可以通过python manage.py createsuperuser 在终端交互输入用户名和密码即可

创建超级管理员, (密码输入时终端暂时显示)

进入后台: 127.0.0.1:8000/admin

五、各功能代码位置介绍:

标签分类: 数据库设计Movie通过外键关联Tags表,

电影搜索: 在views.py search方法中。通过电影名,导演名,介绍去进行关键字搜索。

后台管理: 通过django自带的admin后台加插件 在admins.py中注册数据库模型

两种推荐算法: 都在recommend_movies.py文件中。

推荐显示的代码:

前端: items.html

后端: views.py中 388行 user_recommend 传递数据到前端template

算法:recommend_movies.py。

六、依赖包和框架版本

(venv) E:\movie>pip list

Package Version

aiohttp 3.7.4.

asgiref 3.3.4

async-timeout 3.0.1

attrs 21.2.0

beautifulsoup4 4.9.3

bs4 0.0.1

certifi 2020.12.5

chardet 4.0.0

crawler 0.0.2

Django 2.2.10

django-simpleui 2.1

djangorestframework 3.9.1

greenlet 1.1.0

idna 2.10

idna-ssl 1.1.0

importlib-metadata 4.0.1

lxml 4.6.3

multidict 5.1.0

七、安装运行方法

1.解压项目,解压的文件夹目录下有movie,用pycharm打开movie目录。

2.在pycharm配置python解释器,3.7及以下都可以。可以通过conda或者其他的虚拟环境来安装。

3.打开终端 输入pip install -r requirements.txt 若提示无pip。去下载get-pip.py 运行python get-pip.py

4.安装成功后, 使用pip list 查看已经安装好的package,和requirements.txt中的进行对比,确认安装无误。

有两种运行方法:

1.通过命令行/cmd运行: python manage.py runserver

2.通过Pycharm专业版配置运行,右上角选中movie,一键运行,第一次运行时间可能比较长,因为需要将item_recommend的相似矩阵计算出来。将模型保存到本地。

Guess you like

Origin blog.csdn.net/2201_75772776/article/details/129399905