The Applied Artificial Intelligence Workshop

Book description

With knowledge and information shared by experts, take your first steps towards creating scalable AI algorithms and solutions in Python, through practical exercises and engaging activities

Key Features

  • Learn about AI and ML algorithms from the perspective of a seasoned data scientist
  • Get practical experience in ML algorithms, such as regression, tree algorithms, clustering, and more
  • Design neural networks that emulate the human brain

Book Description

You already know that artificial intelligence (AI) and machine learning (ML) are present in many of the tools you use in your daily routine. But do you want to be able to create your own AI and ML models and develop your skills in these domains to kickstart your AI career?

The Applied Artificial Intelligence Workshop gets you started with applying AI with the help of practical exercises and useful examples, all put together cleverly to help you gain the skills to transform your career.

The book begins by teaching you how to predict outcomes using regression. You'll then learn how to classify data using techniques such as k-nearest neighbor (KNN) and support vector machine (SVM) classifiers. As you progress, you'll explore various decision trees by learning how to build a reliable decision tree model that can help your company find cars that clients are likely to buy. The final chapters will introduce you to deep learning and neural networks. Through various activities, such as predicting stock prices and recognizing handwritten digits, you'll learn how to train and implement convolutional neural networks (CNNs) and recurrent neural networks (RNNs).

By the end of this applied AI book, you'll have learned how to predict outcomes and train neural networks and be able to use various techniques to develop AI and ML models.

What you will learn

  • Create your first AI game in Python with the minmax algorithm
  • Implement regression techniques to simplify real-world data
  • Experiment with classification techniques to label real-world data
  • Perform predictive analysis in Python using decision trees and random forests
  • Use clustering algorithms to group data without manual support
  • Learn how to use neural networks to process and classify labeled images

Who this book is for

The Applied Artificial Intelligence Workshop is designed for software developers and data scientists who want to enrich their projects with machine learning. Although you do not need any prior experience in AI, it is recommended that you have knowledge of high school-level mathematics and at least one programming language, preferably Python. Although this is a beginner's book, experienced students and programmers can improve their Python skills by implementing the practical applications given in this book.

Table of contents

  1. The Applied Artificial Intelligence Workshop
  2. Preface
    1. About the Book
      1. Audience
      2. About the Chapters
      3. Conventions
      4. Code Presentation
      5. Setting up Your Environment
      6. Installing Jupyter on Your System
      7. Launching the Jupyter Notebook
      8. Installing Libraries
      9. A Few Important Packages
      10. Accessing the Code Files
  3. 1. Introduction to Artificial Intelligence
    1. Introduction
      1. How Does AI Solve Problems?
      2. Diversity of Disciplines in AI
    2. Fields and Applications of AI
      1. Simulation of Human Behavior
      2. Simulating Intelligence – the Turing Test
        1. What Disciplines Do We Need to Pass the Turing Test?
    3. AI Tools and Learning Models
      1. Intelligent Agents
    4. The Role of Python in AI
      1. Why Is Python Dominant in Machine Learning, Data Science, and AI?
      2. Anaconda in Python
      3. Python Libraries for AI
      4. A Brief Introduction to the NumPy Library
      5. Exercise 1.01: Matrix Operations Using NumPy
    5. Python for Game AI
      1. Intelligent Agents in Games
      2. Breadth First Search and Depth First Search
        1. Breadth First Search (BFS)
        2. Depth First Search (DFS)
      3. Exploring the State Space of a Game
      4. Estimating the Number of Possible States in a Tic-Tac-Toe Game
      5. Exercise 1.02: Creating an AI with Random Behavior for the Tic-Tac-Toe Game
      6. Activity 1.01: Generating All Possible Sequences of Steps in a Tic-Tac-Toe Game
      7. Exercise 1.03: Teaching the Agent to Win
      8. Defending the AI against Losses
      9. Activity 1.02: Teaching the Agent to Realize Situations When It Defends Against Losses
      10. Activity 1.03: Fixing the First and Second Moves of the AI to Make It Invincible
    6. Heuristics
      1. Uninformed and Informed Searches
      2. Creating Heuristics
      3. Admissible and Non-Admissible Heuristics
      4. Heuristic Evaluation
        1. Heuristic 1: Simple Evaluation of the Endgame
        2. Heuristic 2: Utility of a Move
      5. Exercise 1.04: Tic-Tac-Toe Static Evaluation with a Heuristic Function
      6. Using Heuristics for an Informed Search
      7. Types of Heuristics
    7. Pathfinding with the A* Algorithm
      1. Exercise 1.05: Finding the Shortest Path Using BFS
    8. Introducing the A* Algorithm
      1. A* Search in Practice Using the simpleai Library
    9. Game AI with the Minmax Algorithm and Alpha-Beta Pruning
      1. Search Algorithms for Turn-Based Multiplayer Games
    10. The Minmax Algorithm
      1. Optimizing the Minmax Algorithm with Alpha-Beta Pruning
    11. DRYing Up the Minmax Algorithm – the NegaMax Algorithm
      1. Using the EasyAI Library
      2. Activity 1.04: Connect Four
    12. Summary
  4. 2. An Introduction to Regression
    1. Introduction
    2. Linear Regression with One Variable
      1. Types of Regression
      2. Features and Labels
      3. Feature Scaling
      4. Splitting Data into Training and Testing
      5. Fitting a Model on Data with scikit-learn
      6. Linear Regression Using NumPy Arrays
      7. Fitting a Model Using NumPy Polyfit
        1. Plotting the Results in Python
      8. Predicting Values with Linear Regression
      9. Exercise 2.01: Predicting the Student Capacity of an Elementary School
    3. Linear Regression with Multiple Variables
      1. Multiple Linear Regression
      2. The Process of Linear Regression
      3. Importing Data from Data Sources
      4. Loading Stock Prices with Yahoo Finance
      5. Exercise 2.02: Using Quandl to Load Stock Prices
      6. Preparing Data for Prediction
      7. Exercise 2.03: Preparing the Quandl Data for Prediction
      8. Performing and Validating Linear Regression
      9. Predicting the Future
    4. Polynomial and Support Vector Regression
      1. Polynomial Regression with One Variable
      2. Exercise 2.04: First-, Second-, and Third-Degree Polynomial Regression
      3. Polynomial Regression with Multiple Variables
    5. Support Vector Regression
      1. Support Vector Machines with a 3-Degree Polynomial Kernel
      2. Activity 2.01: Boston House Price Prediction with Polynomial Regression of Degrees 1, 2, and 3 on Multiple Variables
    6. Summary
  5. 3. An Introduction to Classification
    1. Introduction
    2. The Fundamentals of Classification
      1. Exercise 3.01: Predicting Risk of Credit Card Default (Loading the Dataset)
    3. Data Preprocessing
      1. Exercise 3.02: Applying Label Encoding to Transform Categorical Variables into Numerical Variables
      2. Identifying Features and Labels
      3. Splitting Data into Training and Testing Using Scikit-Learn
    4. The K-Nearest Neighbors Classifier
      1. Introducing the K-Nearest Neighbors Algorithm (KNN)
      2. Distance Metrics With K-Nearest Neighbors Classifier in Scikit-Learn
        1. The Euclidean Distance
      3. The Manhattan/Hamming Distance
      4. Exercise 3.03: Illustrating the K-Nearest Neighbors Classifier Algorithm in Matplotlib
      5. Parameterization of the K-Nearest Neighbors Classifier in scikit-learn
      6. Exercise 3.04: K-Nearest Neighbors Classification in scikit-learn
      7. Activity 3.01: Increasing the Accuracy of Credit Scoring
    5. Classification with Support Vector Machines
      1. What Are Support Vector Machine Classifiers?
      2. Understanding Support Vector Machines
      3. Support Vector Machines in scikit-learn
      4. Parameters of the scikit-learn SVM
      5. Activity 3.02: Support Vector Machine Optimization in scikit-learn
    6. Summary
  6. 4. An Introduction to Decision Trees
    1. Introduction
    2. Decision Trees
      1. Entropy
      2. Exercise 4.01: Calculating Entropy
      3. Information Gain
      4. Gini Impurity
      5. Exit Condition
      6. Building Decision Tree Classifiers Using scikit-learn
      7. Performance Metrics for Classifiers
      8. Exercise 4.02: Precision, Recall, and F1 Score Calculation
      9. Evaluating the Performance of Classifiers with scikit-learn
    3. The Confusion Matrix
      1. Activity 4.01: Car Data Classification
    4. Random Forest Classifier
      1. Random Forest Classification Using scikit-learn
      2. The Parameterization of the Random Forest Classifier
      3. Feature Importance
      4. Cross-Validation
      5. Extremely Randomized Trees
      6. Activity 4.02: Random Forest Classification for Your Car Rental Company
    5. Summary
  7. 5. Artificial Intelligence: Clustering
    1. Introduction
    2. Defining the Clustering Problem
    3. Clustering Approaches
      1. Clustering Algorithms Supported by scikit-learn
    4. The K-Means Algorithm
      1. Exercise 5.01: Implementing K-Means in scikit-learn
      2. The Parameterization of the K-Means Algorithm in scikit-learn
      3. Exercise 5.02: Retrieving the Center Points and the Labels
      4. K-Means Clustering of Sales Data
      5. Activity 5.01: Clustering Sales Data Using K-Means
    5. The Mean Shift Algorithm
      1. Exercise 5.03: Implementing the Mean Shift Algorithm
      2. The Mean Shift Algorithm in scikit-learn
      3. Hierarchical Clustering
      4. Agglomerative Hierarchical Clustering in scikit-learn
    6. Clustering Performance Evaluation
      1. The Adjusted Rand Index
      2. The Adjusted Mutual Information
      3. The V-Measure, Homogeneity, and Completeness
      4. The Fowlkes-Mallows Score
      5. The Contingency Matrix
      6. The Silhouette Coefficient
      7. The Calinski-Harabasz Index
      8. The Davies-Bouldin Index
      9. Activity 5.02: Clustering Red Wine Data Using the Mean Shift Algorithm and Agglomerative Hierarchical Clustering
    7. Summary
  8. 6. Neural Networks and Deep Learning
    1. Introduction
    2. Artificial Neurons
    3. Neurons in TensorFlow
      1. Exercise 6.01: Using Basic Operations and TensorFlow Constants
    4. Neural Network Architecture
      1. Weights
      2. Biases
      3. Use Cases for ANNs
    5. Activation Functions
      1. Sigmoid
      2. Tanh
      3. ReLU
      4. Softmax
      5. Exercise 6.02: Activation Functions
    6. Forward Propagation and the Loss Function
    7. Backpropagation
    8. Optimizers and the Learning Rate
      1. Exercise 6.03: Classifying Credit Approval
    9. Regularization
      1. Exercise 6.04: Predicting Boston House Prices with Regularization
      2. Activity 6.01: Finding the Best Accuracy Score for the Digits Dataset
    10. Deep Learning
      1. Shallow versus Deep Networks
    11. Computer Vision and Image Classification
      1. Convolutional Neural Networks (CNNs)
      2. Convolutional Operations
      3. Pooling Layer
      4. CNN Architecture
      5. Activity 6.02: Evaluating a Fashion Image Recognition Model Using CNNs
    12. Recurrent Neural Networks (RNNs)
      1. RNN Layers
      2. The GRU Layer
      3. The LSTM Layer
      4. Activity 6.03: Evaluating a Yahoo Stock Model with an RNN
      5. Hardware for Deep Learning
      6. Challenges and Future Trends
    13. Summary
  9. Appendix
    1. 1. Introduction to Artificial Intelligence
      1. Activity 1.01: Generating All Possible Sequences of Steps in a Tic-Tac-Toe Game
      2. Activity 1.02: Teaching the Agent to Realize Situations When It Defends Against Losses
      3. Activity 1.03: Fixing the First and Second Moves of the AI to Make It Invincible
      4. Activity 1.04: Connect Four
    2. 2. An Introduction to Regression
      1. Activity 2.01: Boston House Price Prediction with Polynomial Regression of Degrees 1, 2, and 3 on Multiple Variables
    3. 3. An Introduction to Classification
      1. Activity 3.01: Increasing the Accuracy of Credit Scoring
      2. Activity 3.02: Support Vector Machine Optimization in scikit-learn
    4. 4. An Introduction to Decision Trees
      1. Activity 4.01: Car Data Classification
      2. Activity 4.02: Random Forest Classification for Your Car Rental Company
    5. 5. Artificial Intelligence: Clustering
      1. Activity 5.01: Clustering Sales Data Using K-Means
      2. Activity 5.02: Clustering Red Wine Data Using the Mean Shift Algorithm and Agglomerative Hierarchical Clustering
    6. 6. Neural Networks and Deep Learning
      1. Activity 6.01: Finding the Best Accuracy Score for the Digits Dataset
      2. Activity 6.02: Evaluating a Fashion Image Recognition Model Using CNNs
      3. Activity 6.03: Evaluating a Yahoo Stock Model with an RNN

Product information

  • Title: The Applied Artificial Intelligence Workshop
  • Author(s): Anthony So, William So, Zsolt Nagy
  • Release date: July 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800205819