Giter Club home page Giter Club logo

analytics-vidhya-ibm-recommendation's Introduction

Banner

Private Leaderboard:

  • Score: 0.326319211973979

Public Leaderboard:

  • Score: 0.321784658100713

Challenge:

The challenge is to build a recommendation engine for a retailer based on users purchase history and expose the ML model as a rest service. The train and test dataset comprised of disjoint set of users and their past purchases, country and time of purchase.

Solution:

Recommendation Engine

  • The final recommendation engine is build with Apple's Turi Create using Item Similarity Recommender.

  • A Django Rest API to expose the ML model as service, hosted on Heroku.

REST API

The Django app has two API end points

  • User based recommendation, given a user_id and an optional k for number of item recommendations required, estimator will predict k number of items.

  • Basket based recommendation, given list of items in user basket and an optional k number of item recommendation required, estimator will predict k number of items

  • Default value for k is 10

NOTE: The endpoints have a browsable django rest framework document, can also be accessed via Postman. The api are hosted in Heroku, the apps may have been put to sleep by Heroku if there is no web traffic, so please give it a few minuit on first request to spin up the containers.

User Based Recommendation

End Point: https://<YOUR_APP_NAME_HERE>.herokuapp.com/recommend/user

HTTP Method: POST

Payload:

  • user: required parameter it can be any user from the given dataset.

  • k: number of required items recommendation, default is 10.

Sample Json Payload:

      { 

        "user": 27270,   

        "k": 3  

      }   

Sample Json Output:

     { 
        "top_recommendation": [
            "21212D",
            "22178V",
            "22720A"
        ],
        "score": {
            "21212D": 0.1528126357532129,
            "22178V" 0.1359131576084509,
            "22720A": 0.13515295197324054
        },
        "estimator": "ItemSimilarityRecommender"
    } 

Items Based Recommendation

End Point: https://<YOUR_APP_NAME_HERE>.herokuapp.com/recommend/items

HTTP Method: POST

Payload:

  • items: required parameter it can be any item from the given dataset.

  • k: number of required items recommendation, default is 10.

Sample Json Payload:

    {    
    "items": ["21212D", "22720A"],    
    "k": 5 
    } 

Sample Json Output:

    {     
        "top_recommendation": [
            "47566Y",
            "85099BJ",
            "85123AY",
            "22423U",
            "22666I"
        ],
        "score": { 
            "47566Y": 0.47120603919029236,
            "85099BJ": 0.470460444688797,
            "85123AY": 0.4658285975456238, 
            "22423U": 0.4650574326515198, 
            "22666I": 0.4602021276950836 
        }, 
        "estimator": "ItemSimilarityRecommender" 
    }

API Deployment Instruction

Read below instruction to deploy the api in your own free Heroku account.

A barebones Django app, which can easily be deployed to Heroku.

This application supports the Getting Started with Python on Heroku article - check it out.

Running Locally

Make sure you have Python 3.7 installed locally. To push to Heroku, you'll need to install the Heroku CLI, as well as Postgres.

$ git clone https://github.com/heroku/python-getting-started.git
$ cd python-getting-started

$ python3 -m venv getting-started
$ pip install -r requirements.txt

$ createdb python_getting_started

$ python manage.py migrate
$ python manage.py collectstatic

$ heroku local

Your app should now be running on localhost:5000.

Deploying to Heroku

$ heroku create
$ git push heroku master

$ heroku run python manage.py migrate
$ heroku open

or

Deploy

Documentation

For more information about using Python on Heroku, see these Dev Center articles:

analytics-vidhya-ibm-recommendation's People

Contributors

nixphix avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.