Successfully reported this slideshow.
Your SlideShare is downloading. ×

Build a Recommendation Engine using Amazon Machine Learning in Real-time

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 51 Ad

Build a Recommendation Engine using Amazon Machine Learning in Real-time

Download to read offline

Amazon Machine Learning is a service that makes it easy for developers of all skill levels to use machine learning technology. In this session, we will introduce how to use Amazon Machine Learning to create a data model, and use it to generate the real-time prediction for your application.

Amazon Machine Learning is a service that makes it easy for developers of all skill levels to use machine learning technology. In this session, we will introduce how to use Amazon Machine Learning to create a data model, and use it to generate the real-time prediction for your application.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Build a Recommendation Engine using Amazon Machine Learning in Real-time (20)

Advertisement

More from Amazon Web Services (20)

Recently uploaded (20)

Advertisement

Build a Recommendation Engine using Amazon Machine Learning in Real-time

  1. 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. John Chang Ecosystem Solutions Architect September 2016 Build a Recommendation Engine and Use Amazon ML in Real Time
  2. 2. Agenda • Machine learning and the data ecosystem • Smart applications by example (and counterexample) • Amazon Machine Learning (Amazon ML) features and benefits • Developing with Amazon ML • Q&A
  3. 3. Three types of data-driven development Retrospective analysis and reporting Amazon Redshift, Amazon RDS Amazon S3 Amazon EMR
  4. 4. Three types of data-driven development Retrospective analysis and reporting Here-and-now real-time processing and dashboards Amazon Kinesis Amazon EC2 AWS Lambda Amazon Redshift, Amazon RDS Amazon S3 Amazon EMR
  5. 5. Three types of data-driven development Retrospective analysis and reporting Here-and-now real-time processing and dashboards Predictions to enable smart applications Amazon Kinesis Amazon EC2 AWS Lambda Amazon Redshift, Amazon RDS Amazon S3 Amazon EMR
  6. 6. Machine learning and smart applications Machine learning is the technology that automatically finds patterns in your data and uses them to make predictions for new data points as they become available.
  7. 7. Machine learning and smart applications Machine learning is the technology that automatically finds patterns in your data and uses them to make predictions for new data points as they become available. Your data + machine learning = smart applications
  8. 8. Smart applications by example Based on what you know about the user: Will they use your product?
  9. 9. Smart applications by example Based on what you know about the user: Will they use your product? Based on what you know about an order: Is this order fraudulent?
  10. 10. Smart applications by example Based on what you know about the user: Will they use your product? Based on what you know about an order: Is this order fraudulent? Based on what you know about a news article: What other articles are interesting?
  11. 11. And a few more examples… Fraud detection Detecting fraudulent transactions, filtering spam emails, flagging suspicious reviews,… Personalization Recommending content, predictive content loading, improving user experience,… Targeted marketing Matching customers and offers, choosing marketing campaigns, cross-selling and up-selling,… Content classification Categorizing documents, matching hiring managers and resumes,… Churn prediction Finding customers who are likely to stop using the service, upgrade targeting,… Customer support Predictive routing of customer emails, social media listening,…
  12. 12. Smart applications by counterexample Dear Alex, This awesome quadcopter is on sale for just $49.99!
  13. 13. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer GROUP BY c.ID HAVING o.date > GETDATE() – 30 We can start by sending the offer to all customers who placed an order in the last 30 days
  14. 14. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer GROUP BY c.ID HAVING O.CATEGORY = ‘TOYS’ AND o.date > GETDATE() – 30 …let’s narrow it down to just customers who bought toys
  15. 15. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN PRODUCTS P ON P.ID = O.PRODUCT GROUP BY c.ID HAVING o.category = ‘toys’ AND ((P.DESCRIPTION LIKE ‘%HELICOPTER%’ AND O.DATE > GETDATE() - 60) OR (COUNT(*) > 2 AND SUM(o.price) > 200 AND o.date > GETDATE() – 30) ) …and expand the query to customers who purchased other toy helicopters recently, or made several expensive toy purchases
  16. 16. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%COPTER%’ AND o.date > GETDATE() - 60) OR (COUNT(*) > 2 AND SUM(o.price) > 200 AND o.date > GETDATE() – 30) ) …but what about quadcopters?
  17. 17. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%copter%’ AND o.date > GETDATE() - 120) OR (COUNT(*) > 2 AND SUM(o.price) > 200 AND o.date > GETDATE() – 30) ) …maybe we should go back further in time
  18. 18. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%copter%’ AND o.date > GETDATE() - 120) OR (COUNT(*) > 2 AND SUM(o.price) > 200 AND o.date > GETDATE() – 40) ) …tweak the query more
  19. 19. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%copter%’ AND o.date > GETDATE() - 120) OR (COUNT(*) > 2 AND SUM(o.price) > 150 AND o.date > GETDATE() – 40) ) …again
  20. 20. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%copter%’ AND o.date > GETDATE() - 90) OR (COUNT(*) > 2 AND SUM(o.price) > 150 AND o.date > GETDATE() – 40) ) …and again
  21. 21. Smart applications by counterexample SELECT c.ID FROM customers c LEFT JOIN orders o ON c.ID = o.customer LEFT JOIN products p ON p.ID = o.product GROUP BY c.ID HAVING o.category = ‘toys’ AND ((p.description LIKE ‘%copter%’ AND o.date > GETDATE() - 90) OR (COUNT(*) > 2 AND SUM(o.price) > 150 AND o.date > GETDATE() – 40) ) Use machine learning technology to learn your business rules from data!
  22. 22. Why aren’t there more smart applications? 1. Machine learning expertise is rare. 2. Building and scaling machine learning technology is hard. 3. Closing the gap between models and applications is time-consuming and expensive.
  23. 23. Building smart applications today Expertise Technology Operationalization Limited supply of data scientists Many choices, few mainstays Complex and error-prone data workflows Expensive to hire or outsource Difficult to use and scale Custom platforms and APIs Many moving pieces lead to custom solutions every time Reinventing the model lifecycle management wheel
  24. 24. What if there were a better way?
  25. 25. Introducing Amazon Machine Learning Easy-to-use, managed machine learning service built for developers Robust, powerful machine learning technology based on Amazon’s internal systems Create models using your data already stored in the AWS cloud Deploy models to production in seconds
  26. 26. Easy-to-use and developer-friendly Use the intuitive, powerful service console to build and explore your initial models • Data retrieval • Model training, quality evaluation, fine-tuning • Deployment and management Automate model lifecycle with fully featured APIs and SDKs • Java, Python, .NET, JavaScript, Ruby, PHP Easily create smart iOS and Android applications with AWS Mobile SDK
  27. 27. Powerful machine learning technology Based on Amazon’s battle-hardened internal systems Not just the algorithms: • Smart data transformations • Input data and model quality alerts • Built-in industry best practices Grows with your needs • Train on up to 100 GB of data • Generate billions of predictions • Obtain predictions in batches or real-time
  28. 28. Integrated with the AWS data ecosystem Access data that is stored in Amazon S3, Amazon Redshift, or MySQL databases in Amazon RDS Output predictions to Amazon S3 for easy integration with your data flows Use AWS Identity and Access Management (IAM) for fine-grained data access permission policies
  29. 29. Fully-managed model and prediction services End-to-end service, with no servers to provision and manage One-click production model deployment Programmatically query model metadata to enable automatic retraining workflows Monitor prediction usage patterns with Amazon CloudWatch metrics
  30. 30. Pay-as-you-go and inexpensive Data analysis, model training, and evaluation: $0.42/instance hour Batch predictions: $0.10/1000 Real-time predictions: $0.10/1000 + hourly capacity reservation charge
  31. 31. Three supported types of predictions Binary classification Predict the answer to a Yes/No question Multiclass classification Predict the correct category from a list Regression Predict the value of a numeric variable
  32. 32. Train model Evaluate and optimize Retrieve predictions 1 2 3 Building smart applications with Amazon ML
  33. 33. Train model Evaluate and optimize Retrieve predictions 1 2 3 Building smart applications with Amazon ML - Create a datasource object pointing to your data - Explore and understand your data - Transform data and train your model
  34. 34. Create a datasource object >>> import boto >>> ml = boto.connect_machinelearning() >>> ds = ml.create_data_source_from_s3( data_source_id = ’my_datasource', data_spec = { 'DataLocationS3': 's3://bucket/input/data.csv', 'DataSchemaLocationS3': 's3://bucket/input/data.schema', ’compute_statistics’: True } )
  35. 35. Explore and understand your data
  36. 36. Train your model >>> import boto >>> ml = boto.connect_machinelearning() >>> model = ml.create_ml_model( ml_model_id = ’my_model', ml_model_type = 'REGRESSION', training_data_source_id = 'my_datasource')
  37. 37. Train model Evaluate and optimize Retrieve predictions 1 2 3 Building smart applications with Amazon ML - Measure and understand model quality - Adjust model interpretation
  38. 38. Explore model quality
  39. 39. Fine-tune model interpretation
  40. 40. Fine-tune model interpretation
  41. 41. Train model Evaluate and optimize Retrieve predictions 1 2 3 Building smart applications with Amazon ML - Batch predictions - Real-time predictions
  42. 42. Batch predictions Asynchronous, large-volume prediction generation Request through service console or API Best for applications that deal with batches of data records >>> import boto >>> ml = boto.connect_machinelearning() >>> model = ml.create_batch_prediction( batch_prediction_id = 'my_batch_prediction’, batch_prediction_data_source_id = ’my_datasource’, ml_model_id = ’my_model', output_uri = 's3://examplebucket/output/’)
  43. 43. Real-time predictions Synchronous, low-latency, high-throughput prediction generation Request through service API, server, or mobile SDKs Best for interaction applications that deal with individual data records >>> import boto >>> ml = boto.connect_machinelearning() >>> ml.predict( ml_model_id = ’my_model', predict_endpoint = ’example_endpoint’, record = {’key1':’value1’, ’key2':’value2’}) { 'Prediction': { 'predictedValue': 13.284348, 'details': { 'Algorithm': 'SGD', 'PredictiveModelType': 'REGRESSION’ } } }
  44. 44. Architecture patterns for smart applications
  45. 45. Get predictions with Amazon ML batch API Process data with EMR Raw data in S3 Aggregated data in S3 Predictions in S3 Your application Batch predictions with EMR
  46. 46. Structured data In Amazon Redshift Load predictions into Amazon Redshift - or - Read prediction results directly from S3 Predictions in S3 Get predictions with Amazon ML batch API Your application Batch predictions with Amazon Redshift
  47. 47. Your application Get predictions with Amazon ML real-time API Amazon ML service Real-time predictions for interactive applications
  48. 48. Your application Amazon DynamoDB + Trigger events with Lambda + Get predictions with Amazon ML real-time API Adding predictions to an existing data flow
  49. 49. Recommendation engine Amazon S3 Amazon Redshift Amazon ML Data Cleansing Raw Data Train model Build Models S3 Static Website Predictions
  50. 50. Q&A http://aws.amazon.com/machine-learning
  51. 51. Remember to complete your evaluations!

Editor's Notes

  • In this session, I’d like to tell you about our service, our motivation for building the service, and the types of smart applications it enables our customers to build.
  • Our customers have told us that their uses of data collected as part of their businesses fall into three major categories. First is the retrospective data analysis, where data is collected, stored and analyzed to answer specific questions about what happened in the past. Many of our customers use Amazon S3 to store large volumes of structured data, and then process is with EMR, using tools like Hive and Pig. Others store data in Amazon Redshift, our PB-scale data warehouse, or in traditional database systems that are managed by Amazon RDS. No matter the mechanism, this approach is valuable for understanding how customers use your applications, or how data flows through them, and using this information to improve your businesses. For example, gathering information about how long customers spend in each part of your application, and how often they are able to successfully complete their task can lead to identifying and improving problematic flows in these applications.
  • The second type of data-driven development is to capture the information as it comes in, and use it to immediately take action. Using AWS products like Kinesis, EC2 and Lambda, customers are able to immediately extract value from incoming data streams – for example, by dashboarding the real-time state of their applications, or by building applications that immediately respond to events as they happen. It is very powerful to be able to not only know what has happened to your business in the past, but also what is happening here and now.
  • There is one more step beyond knowing what is happening here and now. We can use the data we already have to make accurate, actionable predictions about what will happen in the future. We can build a new breed of smart applications using these predictions. It’s really exciting.
  • This brings us to machine learning, which is a broad umbrella term for the technology that finds patterns in your existing data, and using them to make predictions on new data points.
  • The equation is simple: you can build smart applications by leveraging your existing data and machine learning technology.
  • Condense these slides into 3-box
  • Condense these slides into 3-box
  • Condense these slides into 3-box
  • Let’s get all customers who placed an order in the last 30 days
  • Narrow this list down to only the customers who bought toys in the last 30 days
  • Toys are a very broad term. I am going to make my query more complex: I will merge order table with the product table, and look for customers who either (a) purchased a toy whose description had the word “helicopter” in the last 60 days, or had an expensive order in the last 30 days.
  • “Helicopter” doesn’t cover everyone I want to reach. Luckily, I can do a fuzzy match on just “copter”. That’s better, right?
  • Maybe I should look further back in time – it’s not every day that one buys an expensive flying toy.
  • 30 days, 40 days, I don’t really know what the right number is.
  • 200 dollars is a lot to spend in a single purchase, let me try to lower that
  • Too many results, let me bring the results in again.
  • Stop. Just stop. We won’t find the right business rule by tweaking SQL queries. And even if we do find a good rule by sheer luck, it will get out of date immediately.

    Machine learning lets us build smart applications by finding patterns in existing data, and making them actionable as predictions.
  • So now that we have seen several examples of smart applications, and talked about how machine learning enables their development, here is an important questions: why aren’t there more smart applications? Our customers tell us that there are three primary barriers:

    JUST READ THE BARRIERS, DON’T GO INTO DETAILS

    One barrier is that you need experts to use ML technology, and there are not enough experts to keep up with the demand. Companies of all size, in all industries are feeling the talent shortage.
    Another barrier is the technology – and specifically, finding the right technology, that scales to their needs
    And a third barrier is being able to tie machine learning into their business applications, to go from having a model to having a product app using that model

  • One barrier is that you need experts to use ML technology, and there are not enough experts to keep up with the demand. Companies of all size, in all industries are feeling the talent shortage. Outsourcing machine learning model and smart application development is a very expensive option.

    Another barrier is the technology. It takes significant time and engineering expertise to build machine learning software that scales to your business. While there are many tools out there, these tools are often oriented at machine learning experts, and are not built for the demands of large datasets with data types often encountered in real-world. And there is a tremendous fragmentation of tooling out there – to build an end-to-end ML application requires not just the learning technology, but also data connectors and transformers to get data to the learning algorithms, deployment technology to make models available, metric computation and evaluation scripts and so on. Our customers tell us that no matter which technology they start with, they end up doing a lot of the engineering work themselves, just to connect all the pieces and make them play nice.

    And a third barrier is being able to tie machine learning into their business applications, to go from having a model to having an application that is using that model. This is the lesson many early adopters of ML technology learned the hard way – much of the ML software that is out there is focused on making ML models, and not on using these models to make predictions. Often, generating predictions is an after-thought, and the prediction generating runtimes can only run on a single machine, are not robust, and are very limited in the volume of predictions, and the latency at which these predictions can arrive. In addition to predictions, work needs to be done on things like automating data pipelines, and managing, updating and retiring models as they are deployed to production. This is a lot of work.

    The end result is this: to do ML today requires teams of engineers and data scientists working together, and much of what they will build can end up being custom code that will not be reused on your next ML application. It is slow, expensive and risky.
  • Today, we have announced Amazon ML, the newest addition to the Amazon Web Services family.

    Amazon ML is easy to use, and intended for developers – people who are already most connected and familiar with data instrumentation, pipelines and storage/

    Amazon ML is based on the same robust ML technology that is already used within Amazon’s internal systems, generating billions of predictions weekly

    Amazon ML is built to make it simple and reliable to use the data that you are already storing in the AWS cloud, in products like Amazon S3, Amazon Redshift and Amazon RD

    And lastly, Amazon ML is built to eliminate the gap between having models and using these models to build smart applications. Production deployment is only a click away – and sometimes you won’t even need that one click.
  • I want to start by talking about ease of use, because it was so incredibly important to us as we built this product. We wanted to make machine learning accessible to all AWS developers. What we know from both our internal experience and speaking with our customers is that using machine learning to build real-world falls into two types. The first stage is experimentation: trying out different data sources, different ways to transform data, different ways to use ML technology to approach a problem. In this stage, it is really helpful to work with interactive tools that let you do many experiments easily.

    The second stage is productizing the models. This involves automating model training, deployment and use – for example, tying the prediction generation activities with your application’s business logic. And there is just no substitute for having a capable API to achieve this – that enables the ML piece to act just as robustly as the rest of your application.

    Most ML toolkits out there do one or the other. We knew that to enable AWS developers to easily use ML we needed to support both types of ML development. And so what you will see in Amazon ML is a powerful service console that enables you to connect to your data source, to train new models, to measure their quality, and to manage these models easily, without writing any code. This enables you to spend more time thinking about your business problem and your data, not tinkering with the technology pieces. Once you have models that are ready to be productized, you have a full API available to deploy these models, to query them for predictions, and to train and evaluate new models on schedule. It’s a complete lifecycle. We have included Amazon ML API support into all the major AWS SDKs. And, we have also bundled prediction querying capability into the AWS mobile SDKs, making it really simple to create mobile applications that use predictions.
  • Next, let’s talk about technology.

    Amazon ML is based on the same ML technology that has long been deployed within Amazon, and is used to generate tens of billions of predictions weekly.

    When I say technology, I mean not just the learning algorithm – which is important but by no means only part of ML systems. Amazon Machine Learning comes with technology that suggests data transformations based on your data that will improve model’s quality – and you are able to use these transformations as they are, or adjust the transformation instructions without writing any data transforming code. Amazon ML also includes functionality to provide alerts when known pitfalls are encountered in your input data – for example, when some attributes have many missing values, or when the model was evaluated with data that is significantly different from what was used to train it. This – ensuring that data is evaluated on a fair dataset is an example of an industry best practice that we have built into the product, among many others, all around the goal of making the resulting models more powerful.

    Finally, a word about speed and scale. Amazon ML can create models from up to 100 GB of data. You can use it to generate billions of predictions, and obtain them in batches or real-time. I will get to the prediction interfaces soon.

  • Binary Classification: predict the answer to a yes/no question
    Is this order fraudulent?
    Will this customer convert?
    Which article should I show next?

    Multi-class classification: predict the correct category from list:
    What is the genre of this movie?
    What is the root cause of this customer contact?

    Regression: predict the value of a numeric variable
    How many units of this item will sell next week?
    How long will this user session last?

  • Example of where false positives are bad: predicting if an email is a spam or not.
    False negative: email is spam, but we mark it as not spam. Business cost: a small amount of annoyance.
    False positive: email is not spam, but we mark it as spam. Business cost: an important messae =
  • Example: my application periodically receives new product descriptions, and needs to classify them into categories. For example, assign genre to movies based on the movie metadata.

    Example: my application aggregates user activity over time period, and then we call the prediction API to decide which of them will need follow-up. E.g. bizdev followup with customers in free tier.


  • Example: my application periodically receives new product descriptions, and needs to classify them into categories. For example, assign genre to movies based on the movie metadata.

    Example: my application aggregates user activity over time period, and then we call the prediction API to decide which of them will need follow-up. E.g. bizdev followup with customers in free tier.


  • This is example of consuming real-time predictions
    Can also add example of consuming batch prediction with EMR
  • This is example of consuming real-time predictions
    Can also add example of consuming batch prediction with EMR

×