Book Image

Machine Learning with AWS

By : Jeffrey Jackovich, Ruze Richards
Book Image

Machine Learning with AWS

By: Jeffrey Jackovich, Ruze Richards

Overview of this book

<p>Machine Learning with AWS is the right place to start if you are a beginner interested in learning useful artificial intelligence (AI) and machine learning skills using Amazon Web Services (AWS), the most popular and powerful cloud platform. You will learn how to use AWS to transform your projects into apps that work at high speed and are highly scalable. From natural language processing (NLP) applications, such as language translation and understanding news articles and other text sources, to creating chatbots with both voice and text interfaces, you will learn all that there is to know about using AWS to your advantage. You will also understand how to process huge numbers of images fast and create machine learning models.</p> <p>By the end of this book, you will have developed the skills you need to efficiently use AWS in your machine learning and artificial intelligence projects.</p>
Table of Contents (9 chapters)
Machine Learning with AWS
Preface

Chapter 2: Summarizing Text Documents Using NLP


Activity 3: Integrating Lambda with Amazon Comprehend to perform text analysis

Note

The "test_s3trigger_configured.txt" is available at the following GitHub repository: https://github.com/TrainingByPackt/Machine-Learning-with-AWS/blob/master/lesson2/topic_c/test_s3trigger_configured.txt

  1. Next, we will upload the "test_s3trigger_configured.txt" file to our S3 bucket to verify the lambda s3_trigger function was configured successfully.

  2. Navigate to the s3 page: https://console.aws.amazon.com/s3/

  3. Click the bucket name you are using to test the s3_trigger function (in my case: "aws-ml-s3-trigger").

    Figure 2.37: S3 bucket list

  4. Click Upload.

    Figure 2.38: S3 bucket list Upload screen

  5. The following screen will display.

    Figure 2.39: S3 Upload bucket "add files" screen.

  6. Click Add files.

    Figure 2.40: S3 Add files selection screen.

  7. Navigate to the "test_s3trigger_configured.txt" file location. Select the file.

  8. Navigate to the text file's location and open the file. The file contains the following text:

  9. "I am a test file to verify the s3 trigger was successfully configured!"

  10. Before we execute the s3_trigger, consider the output based on the following aspects of the text: sentiment (positive, negative, or neutral), entities (quantity, person, place, etc.), and key phrases.

  11. Click Upload.

    Figure 2.41: S3 file added to bucket for Lambda trigger test

  12. Navigate back to the s3_trigger. Click Monitoring

    Figure 2.42: Select Monitoring tab

  13. Click View logs in CloudWatch.

    Figure 2.43: Select the View logs in CloudWatch

  14. Click on the Log Stream.

    Figure 2.44: Select the Log Stream

  15. Select the circle option next to Text to expand the output:

    Figure 2.9: Click the circle option to expand the lambda output

  16. Below is the first few lines of the output, and to see the entire output you need to Scroll down to view all of the results (see below). We will interpret the total output in the next step.

    Figure 2.45: The top portion of the s3_trigger output

  1. Sentiment_response -> Classified as 60.0% likely to be Positive

  2. Sentiment_response:

    {'Sentiment': 'POSITIVE','SentimentScore':{'Positive': 0.6005121469497681,'Negative': 0.029164031147956848, 'Neutral': 0.3588017225265503, 'Mixed': 0.01152205839753151},

    entity_response --> Classified as 70.5% likely the type is Quantity

    entity_response:

    {Entities':[{'Score':0.7053232192993164, 'Type': 'QUANTITY','Text': '3 trigger', 'BeginOffset': 35, 'EndOffset': 44}],

    key_phases_response -> Classified as 89.9% likely "a test file" and 98.5% likely 'the s3 trigger" are the key phrases.

    key_phases_response:

    {'KeyPhrases': [{'Score': 0.8986637592315674, 'Text': 'a test file', 'BeginOffset': 8, 'EndOffset': 19}, {'Score': 0.9852105975151062, 'Text': 'the s3 trigger', 'BeginOffset': 30, 'EndOffset': 44}],