Git Product home page Git Product logo

spark_recommender's Introduction

Product Recommender based on Apache Spark and Elasticsearch

This repository is a just Proof of Cncept (POC) of how to create a Product Recommender using the latest Big Data technologies such as Apache Spark and Elasticsearch.

It is very advisable to read my two articles that refers to this PoC where you can find some theory behind the recommenders and more technical detail:

Technical Requirements

In order to launch this Poc, you must have running:

  • A MongoDB ReplicaSet/Single Instance.
  • An Elasticsearch Cluster/Single Instance.

How to compile it

Just run the following command:

mvn clean compile 

How to run it

This Poc are split in two main parts:

  • RecommenderTrainerApp: pre-calculates the recommendations.
  • RecommenderServerApp: return the recommendations.

es.alvsanand.spark_recommender.RecommenderTrainerApp

This process is the responsible of:

  • Downloads the dataset.
  • Reads and parsing the product catalog and user ratings using Apache Spark (SparkSQL).
  • Stores the catalog/ratings into the databases (MongoDB and Elasticsearch).
  • Trains the Collaborative Filtering (CF) model using the ALS algorithm using Apache Spark (MLlib).
  • Pre-calculates CF recommendations (User-Product and Product-Product) and saving them into DB (MongoDB).

This PoC use this Amazon Dataset.

How to launch trainer

Just run the following command:

mvn exec:java -Dexec.mainClass="es.alvsanand.spark_recommender.RecommenderTrainerApp" -Dexec.args=""
  • These are its parameters:
Recommendation System Trainer
Usage: RecommenderTrainerApp [options]

  --spark.cores <value>
        Number of cores in the Spark cluster
  --spark.option spark.property1=value1,spark.property2=value2,...
        Spark Config Option
  --mongo.uri <value>
        Mongo uri (mongodb://db1.example.net,db2.example.net:27002,db3.example.net:27003/database)
  --mongo.db <value>
        Mongo Database
  --es.httpHosts <value>
        ElasicSearch HTTP Hosts (http://elastic:9200)
  --es.transportHosts <value>
        ElasicSearch Transport Hosts (http://elastic:9300)
  --es.index <value>
        ElasicSearch index
  --maxRecommendations <value>
        Maximum number of recommendations
  --help
        prints this usage text

es.alvsanand.spark_recommender.RecommenderServerApp

It is a REST API server that returns product recommendations. This PoC is able to return the following types of recommendations:

  • Collaborative Filtering:

    • User-Product:

    curl -H "Content-Type: application/json" -XPOST 'localhost:8080/recs/cf/usr' -d '{"userId": 28413167}'

    • Product-Product:

    curl -H "Content-Type: application/json" -XPOST 'localhost:8080/recs/cf/pro' -d '{"productId": 257297861}'

  • Content Based:

    • Search Based:

    curl -H "Content-Type: application/json" -XPOST 'localhost:8080/recs/cb/sch' -d '{"text": "Phone"}'

    • Similar Product:

    curl -H "Content-Type: application/json" -XPOST 'localhost:8080/recs/cb/mrl' -d '{"productId": 257297861}'

  • Hybrid Recommendations (Product-Product CF and Similar Product CB):

    curl -H "Content-Type: application/json" -XPOST 'localhost:8080/recs/hy/pro' -d '{"productId": 257297861}'

How to launch the server

Just run the following command:

mvn exec:java -Dexec.mainClass="es.alvsanand.spark_recommender.RecommenderServerApp" -Dexec.args="--help"
  • These are its parameters:
Recommendation System Server
Usage: RecommenderServerApp [options]

  --server.port <value>
        HTTP server port
  --mongo.uri <value>
        Mongo uri (mongodb://db1.example.net,db2.example.net:27002,db3.example.net:27003/database)
  --mongo.db <value>
        Mongo Database
  --es.httpHosts <value>
        ElasicSearch HTTP Hosts (http://elastic:9200)
  --es.transportHosts <value>
        ElasicSearch Transport Hosts (http://elastic:9300)
  --es.index <value>
        ElasicSearch index
  --help
        prints this usage text

spark_recommender's People

Contributors

alvsanand avatar

Stargazers

Samitha Jayaweera avatar Expanse avatar Rosie avatar Guillermo Portas avatar Faryne avatar iasinDev avatar Bruno Melo avatar  avatar  avatar  avatar Andrea Del Fante avatar M avatar  avatar Mehmet Arı avatar Tuyen Luong avatar  avatar Julian avatar José Fernando Moreno Gutiérrez avatar @alonso_isidoro avatar  avatar Enrique Herreros avatar Alejandro avatar

Watchers

 avatar James Cloos avatar

spark_recommender's Issues

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.