Book Image

Supervised Machine Learning with Python

By : Taylor Smith
Book Image

Supervised Machine Learning with Python

By: Taylor Smith

Overview of this book

Supervised machine learning is used in a wide range of sectors, such as finance, online advertising, and analytics, to train systems to make pricing predictions, campaign adjustments, customer recommendations, and much more by learning from the data that is used to train it and making decisions on its own. This makes it crucial to know how a machine 'learns' under the hood. This book will guide you through the implementation and nuances of many popular supervised machine learning algorithms, and help you understand how they work. You’ll embark on this journey with a quick overview of supervised learning and see how it differs from unsupervised learning. You’ll then explore parametric models, such as linear and logistic regression, non-parametric methods, such as decision trees, and a variety of clustering techniques that facilitate decision-making and predictions. As you advance, you'll work hands-on with recommender systems, which are widely used by online companies to increase user interaction and enrich shopping potential. Finally, you’ll wrap up with a brief foray into neural networks and transfer learning. By the end of this book, you’ll be equipped with hands-on techniques and will have gained the practical know-how you need to quickly and effectively apply algorithms to solve new problems.
Table of Contents (11 chapters)
Title Page
Copyright and Credits
About Packt
Contributor
Preface
Index

Preface

Supervised machine learning is used in a wide range of sectors such as finance, online advertising, and analytics because it allows you to train your system to make pricing predictions, campaign adjustments, customer recommendations, and much more, giving the system the ability to self-adjust and make decisions on its own. The benefits this can give make it crucial to know how a machine learns under the hood.

This book will guide you through the implementation and nuances of many popular supervised machine learning algorithms. You'll embark on this journey with a quick overview and see how supervised machine learning differs from unsupervised learning. After that, we will explore parametric models such as linear and logistic regression, non-parametric methods such as decision trees, and various clustering techniques to facilitate decision-making and predictions. As we proceed, you'll work with recommender systems, which are widely used by online companies to increase user interaction and boost potential sales. Finally, we'll wrap up with a brief foray into neural networks and transfer learning.

By the end of this book, you'll be equipped with hands-on techniques to gain the practical know-how needed to quickly and powerfully apply supervised learning algorithms to new problems.

Who this book is for

This book is for aspiring machine learning developers who want to get started with supervised learning. Intermediate knowledge of Python programming and some fundamental knowledge of supervised learning is expected.

What this book covers

Chapter 1First Step toward Supervised Learning, covers the basics of supervised machine learning to get you prepared to start tackling problems on your own. The chapter comprises four important sections. First, we will get our Anaconda environment set up and make sure that we are able to run the examples. Over the next couple of sections following that, we will cover a bit more of the theory behind machine learning, before we start implementing algorithms in the final section, where we'll get our Anaconda environment set up.

 

 

Chapter 2Implementing Parametric Models, dives into the guts of several popular supervised learning algorithms within the parametric modeling family. We'll start this section by formally introducing parametric models, then we'll focus on two very popular parametric models in particular: linear and logistic regression. We'll spend some time understanding the inner workings and then jump into Python and actually code them from scratch.

Chapter 3, Working with Non-Parametric Models, explores the non-parametric model family. We will start by covering the bias-variance trade-off, and explain how parametric and non-parametric models differ at a fundamental level. We will then get into decision trees and clustering methods. Finally, we'll address some of the pros and cons of non-parametric models.

Chapter 4, Advanced Topics in Supervised ML, splits its time between two topics: recommender systems and neural networks. We'll start with collaborative filtering and then talk about integrating content-based similarities into your collaborative filtering systems. Finally, we'll get into neural networks and transfer learning.

To get the most out of this book

You will need the following software to be able to smoothly sail through the chapters:

  • Jupyter Notebook
  • Anaconda
  • Python

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

 

 

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/Supervised-Machine-Learning-with-Python. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781838825669_ColorImages.pdf.

 

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

from urllib.request import urlretrieve, ProxyHandler, build_opener, install_opener
import requests
import os
pfx = "https://archive.ics.uci.edu/ml/machine-learning databases/spambase/"
data_dir = "data"

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

jupyter notebook

 

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.