Git Product home page Git Product logo

vabarbosa / product-recommendation-with-watson-ml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/product-recommendation-with-watson-ml

0.0 0.0 1.0 10.09 MB

Build a recommendation engine with Spark and Watson Machine Learning

Home Page: https://developer.ibm.com/patterns/build-a-product-recommendation-engine-with-watson-machine-learning/

License: Apache License 2.0

Jupyter Notebook 100.00%

product-recommendation-with-watson-ml's Introduction

Build a product recommendation engine with Watson Machine Learning

In this code pattern historical shopping data is used to build a recommendation engine with Spark and Watson Machine Learning. The model can then used to create a list of recommendations based on contents of a shopping basket.

When you have completed this code patterns, you will understand how to:

  • Use Jupyter Notebooks in IBM Watson Studio
  • Build a recommendation model with SparkML and Watson Machine Learning to provide product recommendations for customers based on their purchase history

The intended audience is data scientists and developers interested in building, deploying and testing machine learning models from a Jupyter notebook with Watson Machine Learning.

Flow

  1. Load the provided notebook into Watson Studio
  2. Load and transform the customer data in the notebook
  3. Build a k-means clustering model with SparkML
  4. Deploy the model to Watson Machine Learning
  5. Test and compare the models build in the notebook and through the Watson Machine Learning API

Included Components

  • IBM Watson Studio: a suite of tools and a collaborative environment for data scientists, developers and domain experts
  • IBM Apache Spark: an open source cluster computing framework optimized for extremely fast and large scale data processing
  • IBM Watson Machine Learning: a set of REST APIs to develop applications that make smarter decisions, solve tough problems, and improve user outcomes
  • Jupyter Notebooks: an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text

Steps

  1. Setup project and data in Watson Studio
  2. Create and deploy a recommendation engine with Watson Studio

1. Setup project and data in Watson Studio

To complete this code pattern we'll need to do a few setup steps before creating our model. In Watson Studio we need to: create a project, add our patient data (which our model will be based on), upload our notebook, and provision a Watson Machine Learning service.

1.1. Create a project in Watson Studio

  • Log into IBM's Watson Studio. Once in, you'll land on the dashboard.

  • Create a new project by clicking + New project and choosing Data Science:

    studio project

  • Enter a name for the project name and click Create.

NOTE: By creating a project in Watson Studio a free tier Object Storage service will be created in your IBM Cloud account. Select the Free storage type to avoid fees.

1.2 Provision a Watson Machine Learning service

  • Click on the navigation menu on the left () to show additional options. Click on the Watson Services option.

    add asset

  • From the overview page, click + Add service on the top right and choose the Machine Learning service. Select the Lite plan to avoid fees.

  • Once provisioned, you should see the service listed in the Watson Services overview page. Select the service by opening the link in a new tab. We're now in the IBM Cloud tool, where we will create service credentials for our now Watson Machine Learning service. Follow the numbered steps in the image below. We'll be using these credentials in Step 2, so keep them handy!.

    wml credentials

  • TIP: You can now go back the project via the navigation menu on the left ().

    add asset

1.3 Create a notebook in Watson Studio

The notebook we'll be using can be viewed in notebooks/wml-product-recommendation-engine.ipynb, and a completed version can be found in examples/wml-product-recommendation-engine-complete.ipynb.

2. Create and deploy a predictive model with Watson Studio

Now that we're in our Notebook editor, we can start to create our predictive model by stepping through the notebook.

2.1 Start stepping through the notebook

  • Click the ▶ Run button to start stepping through the notebook.

  • Keep stepping through the code, pausing on each step to read the code and see the output for the opertion we're performing. At the end of Step 3 we'll have used the K-means Clustering algorithm on Spark ML to create a model. This model associates every customer to a cluster based on their shopping history.

2.2 Save the model

The gist of the next two steps is to use the Watson Machine Learning Python client to persist and deploy the model we just created.

  • At the beginning of Step 5. Persist model, before we deploy our model, we need up update the cell with credentials from our Watson Machine Learning service. (Remember that from Step 1.2 Provision a Watson Machine Learning service?)

  • Update the wml_credentials variable below. Copy and paste the entire credential dictionary, which can be found on the Service Credentials tab of the Watson Machine Learning service instance created on the IBM Cloud.

    credentials-in-nb

  • Keep stepping through the code, pausing on each step to read the code and see the output for the opertion we're performing. At the end of Step 4 we'll have used the Watson Machine Learning service to persist and save our recommendation model! 🎉

2.3 Deploy the model

  • Now let's run Step 5. Deploy model to the IBM cloud of the notebook. Deploy our model so we can have an endpoint to score data against.

    score-url-in-nb

  • In Step 6. Create product recommendations we create functions that query the database to find the most popular items for a cluster and calculate the recommendations based on a given cluster. This produces a list of recommended items based on the products and quantities in a user's cart, which uses Watson Machine Learning to calculate the cluster based on the shopping cart contents.

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

product-recommendation-with-watson-ml's People

Contributors

dolph avatar imgbot[bot] avatar kant avatar ljbennett62 avatar margriet avatar margrietgroenendijk avatar ptitzler avatar scottdangelo avatar stevemar avatar stevemart avatar tanmayb123 avatar tqtran7 avatar vabarbosa avatar

Forkers

rileyseaburg

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.