Book Image

Effective Amazon Machine Learning

By : Alexis Perrier
Book Image

Effective Amazon Machine Learning

By: Alexis Perrier

Overview of this book

Predictive analytics is a complex domain requiring coding skills, an understanding of the mathematical concepts underpinning machine learning algorithms, and the ability to create compelling data visualizations. Following AWS simplifying Machine learning, this book will help you bring predictive analytics projects to fruition in three easy steps: data preparation, model tuning, and model selection. This book will introduce you to the Amazon Machine Learning platform and will implement core data science concepts such as classification, regression, regularization, overfitting, model selection, and evaluation. Furthermore, you will learn to leverage the Amazon Web Service (AWS) ecosystem for extended access to data sources, implement realtime predictions, and run Amazon Machine Learning projects via the command line and the Python SDK. Towards the end of the book, you will also learn how to apply these services to other problems, such as text mining, and to more complex datasets.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface

Preface

Big data and artificial intelligence are ubiquitous part of our everyday lives, fostering a rising, billion-dollar, cloud-based Machine Learning as a Service (MLaaS) industry.

Among the several Machine Learning as a Service platforms currently on the market, Amazon Machine Learning stands out for its simplicity. Amazon Machine Learning was launched in April 2015 with a clear goal of lowering the barrier to predictive analytic by offering a service accessible to companies without the need for highly skilled technical resources, while balancing performance and costs. When combined with the depth of the AWS ecosystem, the Amazon Machine Learning platform makes predictive analytics a natural element of the business data pipeline.

 This book follows the simplification approach of Amazon Machine Learning with two goals: to give you the core data science knowledge needed to use the service to its full potential and to give you the keys to building a fully featured data pipeline centered around predictive analytics, effectively making predictive analytics the driver of your data driven applications.

What this book covers

Chapter 1, Introduction to Machine Learning and Predictive Analytics, this introductory chapter is a general presentation of the Amazon Machine Learning service and the types of predictive analytics problems it can address. We show how the service uses a simple linear model for regression and classification problems, and we present the context for successful predictions with Amazon Machine Learning.

Chapter 2, Machine Learning Definitions and Concepts, this chapter explains the machine learning concepts needed to use the Amazon Machine Learning service and fully understand how it works. What are the preparation techniques used when dealing with raw data? How do we evaluate a predictive model? What strategies are available to remediate poor predictive performances?

Chapter 3, Overview of an Amazon Machine Learning Workflow, this chapter is an overview of a simple Amazon Machine Learning project. The reader will learn how to get started on the Amazon Machine Learning platform, how to set up an account, and how to secure it. We go through a simple numeric prediction problem based on a classic dataset. We describe how to prepare the data, train and select a model, and make predictions.

Chapter 4, Loading and Preparing the Dataset, Amazon ML offers powerful features to transform the data through recipes. Working with a classic dataset, we upload data on S3, implement cross validation, create a schema, and examine available data statistics. We then extend Amazon ML feature engineering and data cleaning capabilities by using Athena, a recently launched AWS SQL service.

Chapter 5, Model Creation, in this chapter, we explore the Amazon ML data transformations and how to apply them through recipes. We train and tune models and select the best ones by analyzing different prediction metrics. We present insights into the Stochastic Gradient Descent algorithm, and the use of different types of regularization. Finally, we analyze the training logs to better understand what goes on under the Amazon ML hood during model training.

Chapter 6,Predictions and Performances, we apply our newly trained models to make predictions on previously unseen data, and we make a final assessment of their performance and robustness. We show how to make batch predictions on a given dataset and how to set up a real-time endpoint for streaming predictions.

Chapter 7, Command Line and SDK, using the AWS web interface to manage and run your projects is time-consuming. In this chapter, we move away from the web interface and start running our projects via the command line with the AWS Command Line Interface (AWS CLI) and the Python SDK with the Boto3 library. We use our new powers to implement cross validation and recursive feature selection.

Chapter 8, Creating Datasources from Redshift, in this chapter, we will use the power of SQL queries to address non-linear datasets. Creating datasources in Redshift gives us the potential for upstream SQL based feature engineering prior to datasource creation. We explore how to upload data from S3 to Redshift, access the database, run queries, and export results.

Chapter 9, Building a Streaming Data Analysis Pipeline, in the final chapter of the book, we extend Amazon ML capabilities by integrating with other AWS services. We build a fully featured streaming data flow integrating AWS Kinesis, Lambda, Redshift, and Machine Learning to implement real time tweets classification.

What you need for this book

This book requires an AWS account, and the ability to run Python 3 (3.5) code examples. We use the latest Anaconda distribution (conda 4.3). The reader should also be able to run basic shell commands in a terminal.  Note that the Amazon Machine Learning service is not part of the free tier AWS offer.

Who this book is for

This book is for Python developers who want to build real-world artificial intelligence applications. This book is friendly to Python beginners, but being familiar with Python would be useful to play around with the code. It will also be useful for experienced Python programmers who are looking to use artificial intelligence techniques in their existing technology stacks.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Set original weight estimation at w_0 = 100g to initialize and a counter."

A block of code is set as follows:

# Create datasource for training
resource = name_id_generation('DS', 'training', trial)
print("Creating datasources for training (%s)"% resource['Name'] )

Any command-line input or output is written as follows:

$ aws s3 cp data/titanic.csv s3://aml.packt/data/ch9/

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Examples of reinforcement learning applications include AlphaGo, Google's world championship Go algorithm, self-driving cars, and semi-autonomous robots."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Effective-Amazon-Machine-Learning. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.