使用Keras,TensorFlow.js,Node.js和Firebase构建,训练和部署Book Recommender系统(第1部分)

Heads up! This an end-to-end article series. In its three parts, I’m going to show you how to train, save, and deploy a recommender model. Specifically, you will understand how to get and process your data, build and train a neural network, package it in an application, and finally serve it over the internet for everyone to see and use.

小心! 这是一个端到端的文章系列。 在这三个部分中,我将向您展示如何训练,保存和部署推荐器模型。 具体来说,您将了解如何获取和处理数据,构建和训练神经网络,将其打包到应用程序中,以及最终通过Internet提供服务,以供所有人查看和使用。

At the end of this tutorial, you’ll have a book recommender application that can suggest books to users based on their history and preferences. We’ll get into the details of how this works shortly, but before that, below is the result of what you’ll be building:

在本教程的最后,您将拥有一个书推荐器应用程序,该应用程序可以根据用户的历史记录和偏好向他们推荐书。 我们将在短期内详细介绍其工作原理,但在此之前,下面是您要构建的结果:

Image for post
Book Recommender Web Application
推荐书Web应用程序

Link to Source Code

链接到源代码

In this first part of the series, you will learn how to build and train the recommender model. In part 2, you’ll learn how to convert and embed the model in a web application, as well as make recommendations. And finally, in part 3, you’ll learn how to deploy your application using Firebase.

在本系列的第一部分中,您将学习如何构建和训练推荐模型。 在第2部分中,您将学习如何转换模型并将其嵌入到Web应用程序中,并提出建议。 最后,在第3部分中,您将学习如何使用Firebase部署应用程序。

目录 (Table of Contents)

  • Introduction to recommender systems

    推荐系统简介
  • Downloading and pre-processing the book dataset

    下载和预处理图书数据集
  • Building the recommendation engine using TensorFlow / Keras

    使用TensorFlow / Keras构建推荐引擎
  • Training and saving the model

    训练并保存模型
  • Visualizing the embedding layer with TensorFlow embedding projector

    使用TensorFlow嵌入投影仪可视化嵌入层
  • Making recommendations for users

    为用户提出建议
  • Conclusion

    结论

推荐系统简介 (Introduction to Recommender Systems)

A recommender system, in simple terms, seeks to model a user’s behavior regarding targeted items and/or products. That is, a recommender system leverages user data to better understand how they interact with items. Items here could be books in a book store, movies on a streaming platform, clothes in an online marketplace, or even friends on Facebook.

简而言之,推荐系统试图对用户有关目标商品和/或产品的行为进行建模。 也就是说,推荐系统利用用户数据来更好地了解用户与项目的交互方式。 这里的项目可能是书店里的书,流媒体平台上的电影,在线市场上的衣服,甚至是Facebook上的朋友。

推荐系统的类型 (Types of Recommender Systems)

There are two primary types of recommender systems:

推荐系统有两种主要类型:

  1. Collaborative Filtering Systems: These types of recommender systems are based on the user’s direct behavior. That is, this system builds a model of the user based on past choices, activities, and preferences. It then uses this knowledge to predict what the user will like based on their similarity to other user profiles.

    协作过滤系统:这些类型的推荐系统基于用户的直接行为。 即,该系统基于过去的选择,活动和偏好来建立用户模型。 然后,它使用此知识基于与其他用户配置文件的相似性来预测用户的需求。

So in essence, collaborative filtering understands how you interact with items, and then finds other users who behave like you—and then recommend what these other users like to you.

因此,从本质上讲,协作筛选了解您如何与项目进行交互,然后找到行为与您类似的其他用户,然后向您推荐这些其他用户的偏好。

2. Content-Based Filtering System: Content-based recommender systems, on the other hand, are based on the items, and not necessarily the users. This method builds an understanding of similarity between items. That is, it recommends items that are similar to each other in terms of properties.

2.基于内容的过滤系统:另一方面,基于内容的推荐系统基于项目,不一定基于用户。 此方法可建立对项目之间相似性的理解。 也就是说,它建议在属性方面彼此相似的项目。

In essence, content-based recommender systems understand the similarity between items, and will recommend items that are similar to the one the user has seen, purchased, or interacted with before.

本质上,基于内容的推荐系统了解项目之间的相似性,并将推荐与用户之前看过,购买过或进行过交互的项目相似的项目。

Image for post
Source) 来源 )

There is a third type of recommender system, known as a hybrid approach. As you can guess, this approach combines the collaborative and content-based approaches to build better and more generalized systems. That is, it basically combines the strength of both approaches.

有第三种推荐系统,称为混合方法。 您可能会猜到,这种方法结合了协作和基于内容的方法来构建更好,更通用的系统。 也就是说,它基本上结合了两种方法的优势。

Image for post

In this article, we’re going to be using a variant of collaborative filtering. That is, we’ll be using a neural network approach to building a collaborative filtering recommender system.

在本文中,我们将使用协作过滤的变体。 也就是说,我们将使用神经网络方法来构建协作式过滤推荐器系统。

We’ll use something called an embedding to build a profile/understanding of the interactions between users and books. This technique falls neither in the collaborative nor content-based approach—I’d say it’s more of a hybrid approach.

我们将使用一种称为嵌入的方法来建立用户/书籍之间交互的配置文件/理解。 该技术既不属于协作方法也不属于基于内容的方法,我想说它更多是一种混合方法。

To do this, we’re going to leverage existing data of books, users, and ratings given by users. A special kind of neural network layer called an embedding is then trained on this interaction, learning the similarity between books in something called an embedding space.

为此,我们将利用图书,用户和用户给出的评分的现有数据。 然后,针对这种相互作用对一种称为嵌入的特殊类型的神经网络层进行训练,从而在称为嵌入空间的东西中学习书籍之间的相似性。

This embedding space helps the neural network better understand the interaction between books and users, and we can leverage this knowledge, combined with the user ratings of each book, to train a neural network. This is a classic regression approach, where the input is the learned embedding of book-user interaction, and the target/labels are book ratings given by the users.

这种嵌入空间有助于神经网络更好地理解书籍与用户之间的互动,我们可以利用这些知识,结合每本书的用户评分来训练神经网络。 这是一种经典的回归方法,其中输入是书本与用户互动的学习性嵌入, 目标/标签是用户给定的书评。

Image for post
The architecture of our Recommender System
推荐系统的架构

Now that you have a basic understanding of the kind of system we’re building, let’s get our data and start writing some code.

既然您对我们正在构建的系统类型有了基本的了解,那么让我们获取数据并开始编写一些代码。

下载和预处理图书数据集 (Downloading and pre-processing the book dataset)

The data used for this tutorial can be download from Kaggle by following this

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值