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 1: Introduction to Amazon Web Services


Activity 1: Importing and exporting the data into S3 with the CLI.

  1. Verify the configuration is correct by executing, "aws s3 ls" to output your bucket name (bucket name will be unique):

    Figure 1.34: Command line

  2. Execute "aws s3 ls <bucket-name>" to output the text file pos_sentiment__leaves_of_grass.txt" in the bucket.

    Figure 1.35: Command line

  3. Create a new S3 bucket with the following command (to note: your bucket name needs to be unique. Refer to the S3 "Rules for Bucket Naming" for specific details):

    Figure 1.36: Command line

  4. In the command prompt, navigate to the "neg_sentiment__dracula.txt" location Execute, "aws s3 cp neg_sentiment__dracula.txt" to import the text file to your S3 bucket.

    Figure 1.37: Command line

  5. Navigate to the "peter_pan.txt" file location with your command line. Import the file "peter_pan.txt" to your S3 bucket (named "aws-test-ml-and-ai-two" in this example) with the following command:

    Figure 1.38: Command line

  6. Navigate to your Desktop in the command line. Create a new local folder named "s3_exported_files" with the command "mkdir s3_exported_files"

    Figure 1.39: Command line

  7. Next, recursively export both files ("neg_sentiment__dracula.txt" and "peter_pan.txt") from the S3 bucket to your local directory with the "- -recursive" parameter. See below for the command's execution.

    Figure 1.40: Command line

  8. Verify the objects were exported successfully to your local folder with the, "dir" command (see below):

    Figure 1.41: Output

Activity 2: Test Amazon Comprehends API features.

In this section, we will learn about display text analysis output using a partial text file input in the API explorer. We will be exploring API's is a skill to save development time by making sure the output is in a desired format for your project. Thus, we will test Comprehend's text analysis features.

We will consider an example suppose you are an entrepreneur creating a chatbot. You identified a business topic and corresponding text documents with content that will allow the chatbot to make your business successful. Your next step is to identify/verify an AWS service to parse the text document for sentiment, language, key phrases, and entities. Before investing time in writing a complete program, you want to test the AWS service's features via the AWS management console's interface. To ensure that it happen correctly, you will need to have search the web for an article (written in English or Spanish) that contains a subject matter (sports, movies, current events, etc.) that you are interested. And, also AWS Management Console accessible via the root user's account

You are aware exploring API's is a skill to save development time by making sure the output is in a desired format for your project.

  1. Click in the Search bar of AWS Services to search the service name

    Figure 1.42: Searching of AWS Service

  2. Search the Amazon Comprehend option and select the option you will be directed. Get started screen.

    Figure 1.43: Selecting the Service

  3. You will be directed to the API explorer. Navigation to Topic modeling and Documentation. The middle is a GUI to explore the API, and the right side provides real-time output for text input.

    Figure 1.44: API Explorer

  4. Click clear text to clear all default services. Navigate to open the following URL in a new tab http://www.gutenberg.org/cache/epub/1322/pg1322.txt

    Figure 1.45: API Explorer Screen

  5. Copy the first poem, and paste it in the Explorer and click Analyze to see the output

    Figure 1.46: Analyzing the Output

  6. Review the right side of the screen for Entity, Key phrases, Language, and scroll down to view Sentiment.

    Figure 1.47: Result

You now know how to explore an API, and how to display sentiment output for the same.