New edition of the bestselling guide to artificial intelligence with Python, updated to Python 3.x and TensorFlow 2, with seven new chapters that cover RNNs, AI & Big Data, fundamental use cases, chatbots, and more. Key Features Completely updated and revised to Python 3.x and TensorFlow 2 New chapters for AI on the cloud, recurrent neural networks, deep learning models, and feature selection and engineering Learn more about deep learning algorithms, machine learning data pipelines, and chatbots Book Description Artificial Intelligence with Python, Second Edition is an updated and expanded version of the bestselling guide to artificial intelligence using the latest version of Python 3.x and TensorFlow 2. Not only does it provide you an introduction to artificial intelligence, this new edition goes further by giving you the tools you need to explore the amazing world of intelligent apps and create your own applications. This edition also includes seven new chapters on more advanced concepts of Artificial Intelligence, including fundamental use cases of AI; machine learning data pipelines; feature selection and feature engineering; AI on the cloud; the basics of chatbots; RNNs and DL models; and AI and Big Data. Finally, this new edition explores various real-world scenarios and teaches you how to apply relevant AI algorithms to a wide swath of problems, starting with the most basic AI concepts and progressively building from there to solve more difficult challenges so that by the end, you will have gained a solid understanding of, and when best to use, these many artificial intelligence techniques. What you will learn Understand what artificial intelligence, machine learning, and data science are Explore the most common artificial intelligence use cases Learn how to build a machine learning pipeline Assimilate the basics of feature selection and feature engineering Identify the differences between supervised and unsupervised learning Discover the most recent advances and tools offered for AI development in the cloud Develop automatic speech recognition systems and chatbots Apply AI algorithms to time series data Who this book is for The intended audience for this book is Python developers who want to build real-world Artificial Intelligence applications. Basic Python programming experience and awareness of machine learning concepts and techniques is mandatory Cover Copyright Packt Page Contributors Table of Contents Preface Chapter 1: Introduction to Artificial Intelligence What is AI? Why do we need to study AI? Branches of AI The five tribes of machine learning Defining intelligence using the Turing test Making machines think like humans Building rational agents General Problem Solver Solving a problem with GPS Building an intelligent agent Types of models Installing Python 3 Installing on Ubuntu Installing on Mac OS X Installing on Windows Installing packages Loading data Summary Chapter 2: Fundamental Use Cases for Artificial Intelligence Representative AI use cases Digital personal assistants and chatbots Personal chauffeur Shipping and warehouse management Human health Knowledge search Recommendation systems The smart home Gaming Movie making Underwriting and deal analysis Data cleansing and transformation Summary References Chapter 3: Machine Learning Pipelines What is a machine learning pipeline? Problem definition Data ingestion Data preparation Missing values Duplicate records or values Feature scaling Inconsistent values Inconsistent date formatting Data segregation Model training Candidate model evaluation and selection Model deployment Performance monitoring Model performance Operational performance Total cost of ownership (TCO) Service performance Summary Chapter 4: Feature Selection and Feature Engineering Feature selection Feature importance Univariate selection Correlation heatmaps Wrapper-based methods Filter-based methods Embedded methods Feature engineering Imputation Outlier management One-hot encoding Log transform Scaling Date manipulation Summary Chapter 5: Classification and Regression Using Supervised Learning Supervised versus unsupervised learning What is classification? Preprocessing data Binarization Mean removal Scaling Normalization Label encoding Logistic regression classifiers The Naïve Bayes classifier Confusion matrixes Support Vector Machines Classifying income data using Support Vector Machines What is regression? Building a single-variable regressor Building a multivariable regressor Estimating housing prices using a Support Vector Regressor Summary Chapter 6: Predictive Analytics with Ensemble Learning What are decision trees? Building a decision tree classifier What is ensemble learning? Building learning models with ensemble learning What are random forests and extremely random forests? Building random forest and extremely random forest classifiers Estimating the confidence measure of the predictions Dealing with class imbalance Finding optimal training parameters using grid search Computing relative feature importance Predicting traffic using an extremely random forest regressor Summary Chapter 7: Detecting Patterns with Unsupervised Learning What is unsupervised learning? Clustering data with the K-Means algorithm Estimating the number of clusters with the Mean Shift algorithm Estimating the quality of clustering with silhouette scores What are Gaussian Mixture Models? Building a classifier based on Gaussian Mixture Models Finding subgroups in stock market using the Affinity Propagation model Segmenting the market based on shopping patterns Summary Chapter 8: Building Recommender Systems Extracting the nearest neighbors Building a K-nearest neighbors classifier Computing similarity scores Finding similar users using collaborative filtering Building a movie recommendation system Summary Chapter 9: Logic Programming What is logic programming? Understanding the building blocks of logic programming Solving problems using logic programming Installing Python packages Matching mathematical expressions Validating primes Parsing a family tree Analyzing geography Building a puzzle solver Summary Chapter 10: Heuristic Search Techniques Is heuristic search artificial intelligence? What is heuristic search? Uninformed versus informed search Constraint satisfaction problems Local search techniques Simulated annealing Constructing a string using greedy search Solving a problem with constraints Solving the region-coloring problem Building an 8-puzzle solver Building a maze solver Summary Chapter 11: Genetic Algorithms and Genetic Programming The evolutionists tribe Understanding evolutionary and genetic algorithms Fundamental concepts in genetic algorithms Generating a bit pattern with predefined parameters Visualizing the evolution Solving the symbol regression problem Building an intelligent robot controller Genetic programming use cases Summary References Chapter 12: Artificial Intelligence on the Cloud Why are companies migrating to the cloud? The top cloud providers Amazon Web Services (AWS) Amazon SageMaker Alexa, Lex, and Polly – conversational gents Amazon Comprehend – natural language processing Amazon Rekognition – image and video Amazon Translate Amazon machine learning Amazon Transcribe – transcription Amazon Textract – document analysis Microsoft Azure Microsoft Azure Machine Learning Studio Azure Machine Learning Service Azure Cognitive Services Google Cloud Platform (GCP) AI Hub Google Cloud AI Building Blocks Summary Chapter 13: Building Games with Artificial Intelligence Using search algorithms in games Combinatorial search The Minimax algorithm Alpha-Beta pruning The Negamax algorithm Installing the easyAI library Building a bot to play Last Coin Standing Building a bot to play Tic-Tac-Toe Building two bots to play Connect FourTM against each other Building two bots to play Hexapawn against each other Summary Chapter 14: Building a Speech Recognizer Working with speech signals Visualizing audio signals Transforming audio signals to the frequency domain Generating audio signals Synthesizing tones to generate music Extracting speech features Recognizing spoken words Summary Chapter 15: Natural Language Processing Introduction and installation of packages Tokenizing text data Converting words to their base forms using stemming Converting words to their base forms using lemmatization Dividing text data into chunks Extracting the frequency of terms using the Bag of Words model Building a category predictor Constructing a gender identifier Building a sentiment analyzer Topic modeling using Latent Dirichlet Allocation Summary Chapter 16: Chatbots The future of chatbots Chatbots today Chatbot concepts A well-architected chatbot Chatbot platforms Creating a chatbot using DialogFlow DialogFlow setup Integrating a chatbot into a website using a widget Integrating a chatbot into a website using Python How to set up a webhook in DialogFlow Enabling webhooks for intents Setting up training phrases for an intent Setting up parameters and actions for an intent Building fulfillment responses from a webhook Checking responses from a webhook Summary Chapter 17: Sequential Data and Time Series Analysis Understanding sequential data Handling time series data with Pandas Slicing time series data Operating on time series data Extracting statistics from time series data Generating data using Hidden Markov Models Identifying alphabet sequences with Conditional Random Fields Stock market analysis Summary Chapter 18: Image Recognition Importance of image recognition OpenCV Frame differencing Tracking objects using color spaces Object tracking using background subtraction Building an interactive object tracker using the CAMShift algorithm Optical flow-based tracking Face detection and tracking Using Haar cascades for object detection Using integral images for feature extraction Eye detection and tracking Summary Chapter 19: Neural Networks Introduction to neural networks Building a neural network Training a neural network Building a Perceptron-based classifier Constructing a single-layer neural network Constructing a multi-layer neural network Building a vector quantizer Analyzing sequential data using recurrent neural networks Visualizing characters in an optical character recognition database Building an optical character recognition engine Summary Chapter 20: Deep Learning with Convolutional Neural Networks The basics of Convolutional Neural Networks Architecture of CNNs CNNs vs. perceptron neural networks Types of layers in a CNN Building a perceptron-based linear regressor Building an image classifier using a single-layer neural network Building an image classifier using a Convolutional Neural Network Summary Reference Chapter 21: Recurrent Neural Networks and Other Deep Learning Models The basics of Recurrent Neural Networks Step function Sigmoid function Tanh function ReLU function Architecture of RNNs A aanguage modeling use case Training an RNN Summary Chapter 22: Creating Intelligent Agents with Reinforcement Learning Understanding what it means to learn Reinforcement learning versus supervised learning Real-world examples of reinforcement learning Building blocks of reinforcement learning Creating an environment Building a learning agent Summary Chapter 23: Artificial Intelligence and Big Data Big data basics Crawling Indexing Ranking Worldwide datacenters Distributed lookups Custom software The three V's of big data Volume Velocity Variety Big data and machine learning Apache Hadoop MapReduce Apache Hive Apache Spark Resilient distributed datasets DataFrames SparkSQL Apache Impala NoSQL Databases Types of NoSQL databases Apache Cassandra MongoDB Redis Neo4j Summary Other Books You May Enjoy Index New edition of the bestselling guide to artificial intelligence with Python, updated to Python 3.x, with seven new chapters that cover RNNs, AI and Big Data, fundamental use cases, chatbots, and more. Key Features Completely updated and revised to Python 3.x New chapters for AI on the cloud, recurrent neural networks, deep learning models, and feature selection and engineering Learn more about deep learning algorithms, machine learning data pipelines, and chatbots Book Description Artificial Intelligence with Python, Second Edition is an updated and expanded version of the bestselling guide to artificial intelligence using the latest version of Python 3.x. Not only does it provide you an introduction to artificial intelligence, this new edition goes further by giving you the tools you need to explore the amazing world of intelligent apps and create your own applications. This edition also includes seven new chapters on more advanced concepts of Artificial Intelligence, including fun damental use cases of AI; machine learning data pipelines; feature selection and feature engineering; AI on the cloud; the basics of chatbots; RNNs and DL models; and AI and Big Data. Finally, this new edition explores various real-world scenarios and teaches you how to apply relevant AI algorithms to a wide swath of problems, starting with the most basic AI concepts and progressively building from there to solve more difficult challenges so that by the end, you will have gained a solid understanding of, and when best to use, these many artificial intelligence techniques. What you will learn Understand what artificial intelligence, machine learning, and data science are Explore the most common artificial intelligence use cases Learn how to build a machine learning pipeline Assimilate the basics of feature selection and feature engineering Identify the differences between supervised and unsupervised learning Discover the most recent advances and tools offered for AI development in the c loud Develop automatic speech recognition systems and chatbots Apply AI algorithms to time series data Who this book is for The intended audience for this book is Python developers who want to build real-world Artificial Intelligence applications. Basic Python programming experience and awareness of machine learning concepts and techniques is mandatory