Hands-On Unsupervised Learning Using Python

Book description

Many industry experts consider unsupervised learning the next frontier in artificial intelligence, one that may hold the key to general artificial intelligence. Since the majority of the world's data is unlabeled, conventional supervised learning cannot be applied. Unsupervised learning, on the other hand, can be applied to unlabeled datasets to discover meaningful patterns buried deep in the data, patterns that may be near impossible for humans to uncover.

Author Ankur Patel shows you how to apply unsupervised learning using two simple, production-ready Python frameworks: Scikit-learn and TensorFlow using Keras. With code and hands-on examples, data scientists will identify difficult-to-find patterns in data and gain deeper business insight, detect anomalies, perform automatic feature engineering and selection, and generate synthetic datasets. All you need is programming and some machine learning experience to get started.

  • Compare the strengths and weaknesses of the different machine learning approaches: supervised, unsupervised, and reinforcement learning
  • Set up and manage machine learning projects end-to-end
  • Build an anomaly detection system to catch credit card fraud
  • Clusters users into distinct and homogeneous groups
  • Perform semisupervised learning
  • Develop movie recommender systems using restricted Boltzmann machines
  • Generate synthetic images using generative adversarial networks

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. A Brief History of Machine Learning
    2. AI Is Back, but Why Now?
    3. The Emergence of Applied AI
    4. Major Milestones in Applied AI over the Past 20 Years
    5. From Narrow AI to AGI
    6. Objective and Approach
    7. Prerequisites
    8. Roadmap
    9. Conventions Used in This Book
    10. Using Code Examples
    11. O’Reilly Online Learning
    12. How to Contact Us
    13. Acknowledgments
  2. I. Fundamentals of Unsupervised Learning
  3. 1. Unsupervised Learning in the Machine Learning Ecosystem
    1. Basic Machine Learning Terminology
    2. Rules-Based vs. Machine Learning
    3. Supervised vs. Unsupervised
      1. The Strengths and Weaknesses of Supervised Learning
      2. The Strengths and Weaknesses of Unsupervised Learning
    4. Using Unsupervised Learning to Improve Machine Learning Solutions
    5. A Closer Look at Supervised Algorithms
      1. Linear Methods
      2. Neighborhood-Based Methods
      3. Tree-Based Methods
      4. Support Vector Machines
      5. Neural Networks
    6. A Closer Look at Unsupervised Algorithms
      1. Dimensionality Reduction
      2. Clustering
      3. Feature Extraction
      4. Unsupervised Deep Learning
      5. Sequential Data Problems Using Unsupervised Learning
    7. Reinforcement Learning Using Unsupervised Learning
    8. Semisupervised Learning
    9. Successful Applications of Unsupervised Learning
      1. Anomaly Detection
    10. Conclusion
  4. 2. End-to-End Machine Learning Project
    1. Environment Setup
      1. Version Control: Git
      2. Clone the Hands-On Unsupervised Learning Git Repository
      3. Scientific Libraries: Anaconda Distribution of Python
      4. Neural Networks: TensorFlow and Keras
      5. Gradient Boosting, Version One: XGBoost
      6. Gradient Boosting, Version Two: LightGBM
      7. Clustering Algorithms
      8. Interactive Computing Environment: Jupyter Notebook
    2. Overview of the Data
    3. Data Preparation
      1. Data Acquisition
      2. Data Exploration
      3. Generate Feature Matrix and Labels Array
      4. Feature Engineering and Feature Selection
      5. Data Visualization
    4. Model Preparation
      1. Split into Training and Test Sets
      2. Select Cost Function
      3. Create k-Fold Cross-Validation Sets
    5. Machine Learning Models (Part I)
      1. Model #1: Logistic Regression
    6. Evaluation Metrics
      1. Confusion Matrix
      2. Precision-Recall Curve
      3. Receiver Operating Characteristic
    7. Machine Learning Models (Part II)
      1. Model #2: Random Forests
      2. Model #3: Gradient Boosting Machine (XGBoost)
      3. Model #4: Gradient Boosting Machine (LightGBM)
    8. Evaluation of the Four Models Using the Test Set
    9. Ensembles
      1. Stacking
    10. Final Model Selection
    11. Production Pipeline
    12. Conclusion
  5. II. Unsupervised Learning Using Scikit-Learn
  6. 3. Dimensionality Reduction
    1. The Motivation for Dimensionality Reduction
      1. The MNIST Digits Database
    2. Dimensionality Reduction Algorithms
      1. Linear Projection vs. Manifold Learning
    3. Principal Component Analysis
      1. PCA, the Concept
      2. PCA in Practice
      3. Incremental PCA
      4. Sparse PCA
      5. Kernel PCA
    4. Singular Value Decomposition
    5. Random Projection
      1. Gaussian Random Projection
      2. Sparse Random Projection
    6. Isomap
    7. Multidimensional Scaling
    8. Locally Linear Embedding
    9. t-Distributed Stochastic Neighbor Embedding
    10. Other Dimensionality Reduction Methods
    11. Dictionary Learning
    12. Independent Component Analysis
    13. Conclusion
  7. 4. Anomaly Detection
    1. Credit Card Fraud Detection
      1. Prepare the Data
      2. Define Anomaly Score Function
      3. Define Evaluation Metrics
      4. Define Plotting Function
    2. Normal PCA Anomaly Detection
      1. PCA Components Equal Number of Original Dimensions
      2. Search for the Optimal Number of Principal Components
    3. Sparse PCA Anomaly Detection
    4. Kernel PCA Anomaly Detection
    5. Gaussian Random Projection Anomaly Detection
    6. Sparse Random Projection Anomaly Detection
    7. Nonlinear Anomaly Detection
    8. Dictionary Learning Anomaly Detection
    9. ICA Anomaly Detection
    10. Fraud Detection on the Test Set
      1. Normal PCA Anomaly Detection on the Test Set
      2. ICA Anomaly Detection on the Test Set
      3. Dictionary Learning Anomaly Detection on the Test Set
    11. Conclusion
  8. 5. Clustering
    1. MNIST Digits Dataset
      1. Data Preparation
    2. Clustering Algorithms
    3. k-Means
      1. k-Means Inertia
      2. Evaluating the Clustering Results
      3. k-Means Accuracy
      4. k-Means and the Number of Principal Components
      5. k-Means on the Original Dataset
    4. Hierarchical Clustering
      1. Agglomerative Hierarchical Clustering
      2. The Dendrogram
      3. Evaluating the Clustering Results
    5. DBSCAN
      1. DBSCAN Algorithm
      2. Applying DBSCAN to Our Dataset
      3. HDBSCAN
    6. Conclusion
  9. 6. Group Segmentation
    1. Lending Club Data
      1. Data Preparation
      2. Transform String Format to Numerical Format
      3. Impute Missing Values
      4. Engineer Features
      5. Select Final Set of Features and Perform Scaling
      6. Designate Labels for Evaluation
    2. Goodness of the Clusters
    3. k-Means Application
    4. Hierarchical Clustering Application
    5. HDBSCAN Application
    6. Conclusion
  10. III. Unsupervised Learning Using TensorFlow and Keras
  11. 7. Autoencoders
    1. Neural Networks
      1. TensorFlow
      2. Keras
    2. Autoencoder: The Encoder and the Decoder
    3. Undercomplete Autoencoders
    4. Overcomplete Autoencoders
    5. Dense vs. Sparse Autoencoders
    6. Denoising Autoencoder
    7. Variational Autoencoder
    8. Conclusion
  12. 8. Hands-On Autoencoder
    1. Data Preparation
    2. The Components of an Autoencoder
    3. Activation Functions
    4. Our First Autoencoder
      1. Loss Function
      2. Optimizer
      3. Training the Model
      4. Evaluating on the Test Set
    5. Two-Layer Undercomplete Autoencoder with Linear Activation Function
      1. Increasing the Number of Nodes
      2. Adding More Hidden Layers
    6. Nonlinear Autoencoder
    7. Overcomplete Autoencoder with Linear Activation
    8. Overcomplete Autoencoder with Linear Activation and Dropout
    9. Sparse Overcomplete Autoencoder with Linear Activation
    10. Sparse Overcomplete Autoencoder with Linear Activation and Dropout
    11. Working with Noisy Datasets
    12. Denoising Autoencoder
      1. Two-Layer Denoising Undercomplete Autoencoder with Linear Activation
      2. Two-Layer Denoising Overcomplete Autoencoder with Linear Activation
      3. Two-Layer Denoising Overcomplete Autoencoder with ReLu Activation
    13. Conclusion
  13. 9. Semisupervised Learning
    1. Data Preparation
    2. Supervised Model
    3. Unsupervised Model
    4. Semisupervised Model
    5. The Power of Supervised and Unsupervised
    6. Conclusion
  14. IV. Deep Unsupervised Learning Using TensorFlow and Keras
  15. 10. Recommender Systems Using Restricted Boltzmann Machines
    1. Boltzmann Machines
      1. Restricted Boltzmann Machines
    2. Recommender Systems
      1. Collaborative Filtering
      2. The Netflix Prize
    3. MovieLens Dataset
      1. Data Preparation
      2. Define the Cost Function: Mean Squared Error
      3. Perform Baseline Experiments
    4. Matrix Factorization
      1. One Latent Factor
      2. Three Latent Factors
      3. Five Latent Factors
    5. Collaborative Filtering Using RBMs
      1. RBM Neural Network Architecture
      2. Build the Components of the RBM Class
      3. Train RBM Recommender System
    6. Conclusion
  16. 11. Feature Detection Using Deep Belief Networks
    1. Deep Belief Networks in Detail
    2. MNIST Image Classification
    3. Restricted Boltzmann Machines
      1. Build the Components of the RBM Class
      2. Generate Images Using the RBM Model
      3. View the Intermediate Feature Detectors
    4. Train the Three RBMs for the DBN
      1. Examine Feature Detectors
      2. View Generated Images
    5. The Full DBN
      1. How Training of a DBN Works
      2. Train the DBN
    6. How Unsupervised Learning Helps Supervised Learning
      1. Generate Images to Build a Better Image Classifier
    7. Image Classifier Using LightGBM
      1. Supervised Only
      2. Unsupervised and Supervised Solution
    8. Conclusion
  17. 12. Generative Adversarial Networks
    1. GANs, the Concept
      1. The Power of GANs
    2. Deep Convolutional GANs
    3. Convolutional Neural Networks
    4. DCGANs Revisited
      1. Generator of the DCGAN
      2. Discriminator of the DCGAN
      3. Discriminator and Adversarial Models
      4. DCGAN for the MNIST Dataset
    5. MNIST DCGAN in Action
      1. Synthetic Image Generation
    6. Conclusion
  18. 13. Time Series Clustering
    1. ECG Data
    2. Approach to Time Series Clustering
      1. k-Shape
    3. Time Series Clustering Using k-Shape on ECGFiveDays
      1. Data Preparation
      2. Training and Evaluation
    4. Time Series Clustering Using k-Shape on ECG5000
      1. Data Preparation
      2. Training and Evaluation
    5. Time Series Clustering Using k-Means on ECG5000
    6. Time Series Clustering Using Hierarchical DBSCAN on ECG5000
    7. Comparing the Time Series Clustering Algorithms
      1. Full Run with k-Shape
      2. Full Run with k-Means
      3. Full Run with HDBSCAN
      4. Comparing All Three Time Series Clustering Approaches
    8. Conclusion
  19. 14. Conclusion
    1. Supervised Learning
    2. Unsupervised Learning
      1. Scikit-Learn
      2. TensorFlow and Keras
    3. Reinforcement Learning
    4. Most Promising Areas of Unsupervised Learning Today
    5. The Future of Unsupervised Learning
    6. Final Words
  20. Index
  21. About the Author

Product information

  • Title: Hands-On Unsupervised Learning Using Python
  • Author(s): Ankur A. Patel
  • Release date: March 2019
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492035640