Skip to content

jscottcronin/recommender_deployed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demonstration of a Deployed Recommender System

The recommender and visualization can be found here: http://52.14.98.50:5000/recommender

This project is best summarized by its parts:

  1. deployment of a factorization machine recommender in a production environment. This includes:

    • Building a deployable factorization machine recommender
    • Building a RESTFUL API for hosting a factorization machine recommender
  2. Building front-end UI for visualizing recommendations and similar items. The visualizations built include:

Building a deployable factorization machine recommender

To demonstrate the deployment of a factorization machine model, I utilize a well studied dataset of 10M interactions between users and movies). I began by first exploring the dataset, followed by implementing methods to clean and prepare the data, and finally modeling. To build the recommendation models, I utilize factorization machine algorithms via lightfm, a wonderful library written by Maciej Kula. Further reading can be found here. Upon building a suitable model, I consolidated the preprocessing and modeling code into a single python class labelled FM. This class was designed for a simplified deployment process.

Jupyter was utilized in the development stage. Some notebooks of interest are:

Next, a deployable train.py script was built. This script executes the following components:

  1. ingests data
  2. preprocesses data
  3. trains factorization machine
  4. serializes factorization machine to disk

Once a model is serialized and stored to disk, it's time to build a RESTFUL API for hosting it.

Building a RESTFUL API for hosting a factorization machine recommender

For real time recommendations, a trained model must be loaded into a server's memory and called behind a RESTFUL endpoint. To setup the server and endpoints, I utilized Flask. The app server code can be found in app_svc.py. We create the following endpoints on our server for real time requests:

Building front-end UI for visualizing recommendations and similar items

Also built into the app server are routes for visualizing the results of the deployed recommender. Specifically, two routes are defined in the server:

  1. http://52.14.98.50:5000/recommender where the route is defined by this server code
  2. http://52.14.98.50:5000/similar_movies where the route is defined by this server code

The GET requests at these routes return a static html. Javascript is utilized to interact with html and make async POST requests to the real-time recommendation endpoints described above. It also enables a nice user experience for engaging and interacting with the deployed recommender model.

About

Example deployment of a factorization machine recommender

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published