Book Image

Artificial Intelligence with Python Cookbook

By : Ben Auffarth
Book Image

Artificial Intelligence with Python Cookbook

By: Ben Auffarth

Overview of this book

Artificial intelligence (AI) plays an integral role in automating problem-solving. This involves predicting and classifying data and training agents to execute tasks successfully. This book will teach you how to solve complex problems with the help of independent and insightful recipes ranging from the essentials to advanced methods that have just come out of research. Artificial Intelligence with Python Cookbook starts by showing you how to set up your Python environment and taking you through the fundamentals of data exploration. Moving ahead, you’ll be able to implement heuristic search techniques and genetic algorithms. In addition to this, you'll apply probabilistic models, constraint optimization, and reinforcement learning. As you advance through the book, you'll build deep learning models for text, images, video, and audio, and then delve into algorithmic bias, style transfer, music generation, and AI use cases in the healthcare and insurance industries. Throughout the book, you’ll learn about a variety of tools for problem-solving and gain the knowledge needed to effectively approach complex problems. By the end of this book on AI, you will have the skills you need to write AI and machine learning algorithms, test them, and deploy them for production.
Table of Contents (13 chapters)

To get the most out of this book

Chapter 1, Getting Started with Artificial Intelligence in Python, goes through the requirements and a suitable setup, along with the installation of an environment in detail, and you'll also learn a lot of practical tricks to become more productive. Generally, you'll need to set up Python with libraries such as scikit-learn, PyTorch, and TensorFlow. We recommend a GPU or online services such as Google Colab. All code samples have been tested on Linux and macOS. Where necessary, however, we comment in relation to Windows operating systems.

Some of the software and libraries most prominently covered in this book are listed in the following table:

Software/hardware covered in the book

OS requirements

Python 3.6 or later

Windows, macOS X, and Linux (any)

TensorFlow 2.0 or later

Windows, macOS X, and Linux (any)

PyTorch 1.6 or later

Windows, macOS X, and Linux (any)

Pandas 1.0 or later

Windows, macOS X, and Linux (any)

Scikit-learn 0.22.0 or later

Windows, macOS X, and Linux (any)

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Artificial-Intelligence-with-Python-Cookbook. 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

You can download the example code files for this book from GitHub at https://static.packt-cdn.com/downloads/9781789133967_ColorImages.pdf. 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!

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: "Here is the simplified code for RangeTransformer."

A block of code is set as follows:

import openml
dataset = openml.datasets.get_dataset(40536)
X, y, categorical_indicator, _ = dataset.get_data(
dataset_format='DataFrame',
target=dataset.default_target_attribute
)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

import operator
operator.sub(1, 2) == 1 - 2
# True

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

$ mkdir css
$ cd css

Bold: Indicates a new term, an important word, or words that you see on screen. 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."

Warnings or important notes appear like this.
Tips and tricks appear like this.