Machine Learning for Predictive Modelling Rory Adams 2015 The MathWorks, Inc. 1
Agenda Machine Learning What is Machine Learning and why do we need it? Common challenges in Machine Learning Example: Human activity learning using mobile phone data Example: Real-time object identification using images Example: Load forecasting using weather data Summary & Key Takeaways 2
Machine Learning is Everywhere Image Recognition Speech Recognition Stock Prediction Medical Diagnosis Data Analytics Robotics and more [TBD] 3
Machine Learning Machine learning uses data and produces a model to perform a task Task: Human Activity Detection Standard Approach Machine Learning Approach Computer Program Machine Learning Hand Written Program If X_acc > 0.5 then SITTING If Y_acc < 4 and Z_acc > 5 then STANDING Formula or Equation Y activity = β 1 X acc + β 2 Y acc + β 3 Z acc + model: Predictors Inputs Outputs Response model = < Machine Learning >(sensor_data, activity) Algorithm 4
Different Types of Learning Machine Learning Supervised Learning Unsupervised Learning Discover a good internal representation Learn a low dimensional representation Classification Response is a choice between classes (True, False) (Red, Blue, Green) Regression Response is a continuous number (temperature, stock prices). 5
Example: Human Activity Learning Using Mobile Phone Data Machine Learning Data: 3-axial Accelerometer data 3-axial Gyroscope data 6
essentially, all models are wrong, but some are useful George Box 7
Challenges in Machine Learning Hard to get started Steps Access, explore and analyze data Preprocess data Train models Assess model performance Challenge Data diversity Numeric, Images, Signals, Text not always tabular Lack of domain tools Filtering and feature extraction Feature selection and transformation Time consuming Train many models to find the best Avoid pitfalls Over Fitting Speed-Accuracy-Complexity tradeoffs Iterate 8
Machine Learning Workflow Train: Iterate till you find the best model LOAD PREPROCESS SUPERVISED LEARNING MODEL FILTERS PCA CLASSIFICATION SUMMARY STATISTICS CLUSTER ANALYSIS REGRESSION Predict: Integrate trained models into applications NEW PREPROCESS MODEL PREDICTION FILTERS PCA SUMMARY STATISTICS CLUSTER ANALYSIS 9
Agenda Machine Learning What is Machine Learning and why do we need it? Common challenges in Machine Learning Example: Human activity learning using mobile phone data Example: Real-time object identification using images Example: Load forecasting using weather data Summary & Key Takeaways 10
Example 1: Human Activity Learning Using Mobile Phone Data Objective: Train a classifier to classify human activity from sensor data Data: Predictors Response 3-axial Accelerometer and Gyroscope data Activity: (Classification) Approach: Extract features from raw sensor signals Train and compare classifiers Test results on new sensor data 11
Machine Learning Workflow for Example 1 Train: Iterate till you find the best model LOAD PREPROCESS SUPERVISED LEARNING MODEL 1. Mean 2. FILTERS Standard PCA deviation 3. PCA SUMMARY STATISTICS CLUSTER ANALYSIS CLASSIFICATION Classification Learner REGRESSION Predict: Integrate trained models into applications TEST PREPROCESS MODEL PREDICTION 1. Mean 2. FILTERS Standard deviation 3. PCA SUMMARY STATISTICS PCA CLUSTER ANALYSIS 12
Agenda Machine Learning What is Machine Learning and why do we need it? Common challenges in Machine Learning Example: Human activity learning using mobile phone data Example: Real-time object identification using images Example: Load forecasting using weather data Summary & Key Takeaways 13
Example 2: Real-time Toy Identification Using Images Objective: Train a classifier to identify toy type from a webcam video Data: Predictors Several images of cars: Response CAR, HELICOPTER, PLANE, BIKE (Classification) Approach: Extract features using Bag-of-words Train and compare classifiers Classify streaming video from a webcam 14
Machine Learning Workflow for Example Train: Iterate till you find the best model LOAD PREPROCESS SUPERVISED LEARNING MODEL 1. Build Bag-offeatures PCA FILTERS 2. Encode images as new features SUMMARY STATISTICS CLUSTER ANALYSIS CLASSIFICATION Classification Learner REGRESSION Predict: Integrate trained models into applications WEBCAM PREPROCESS MODEL PREDICTION Encode FILTERS images PCAas new features SUMMARY STATISTICS CLUSTER ANALYSIS 15
Agenda Machine Learning What is Machine Learning and why do we need it? Common challenges in Machine Learning Example: Human activity learning using mobile phone data Example: Real-time object identification using images Example: Load forecasting using weather data Summary & Key Takeaways 16
Example 3: Day-Ahead System Load Forecasting Objective: Train a neural network to predict the required system load for a zone Data: Predictors Response Temperature, Dew point, Month, Day of week, Prior day load, Prior week load LOAD (Regression) Approach: Extract additional features Train neural network Predict load 17
Machine Learning Workflow for Example 1 Train: Iterate till you find the best model LOAD PREPROCESS SUPERVISED LEARNING MODEL Temp, Dew point Day FILTERS of week SUMMARY STATISTICS PCA Prior day load Prior week load CLUSTER ANALYSIS CLASSIFICATION Neural Network REGRESSION Predict: Integrate trained models into applications TEST PREPROCESS MODEL PREDICTION Temp, Dew point Day FILTERS of week SUMMARY STATISTICS PCA Prior day load Prior week load CLUSTER ANALYSIS 18
Agenda Machine Learning What is Machine Learning and why do we need it? Common challenges in Machine Learning Example: Human activity learning using mobile phone data Example: Real-time object identification using images Example: Load forecasting using weather data Summary & Key Takeaways 19
Challenges in Machine Learning Steps Accessing, exploring and analyzing data Preprocess data Challenge Data diversity Lack of domain tools Train models Assess model performance Time consuming Avoid pitfalls Over Fitting, Speed-Accuracy-Complexity Iterate 20
MATLAB Strengths for Machine Learning Challenge Data diversity Lack of domain tools Time consuming Avoid pitfalls Over Fitting, Speed-Accuracy-Complexity Solution Extensive data support Import and work with signal, images, financial, Textual, geospatial, and several others formats High-quality libraries Industry-standard algorithms for Finance, Statistics, Signal, Image processing & more Interactive, app-driven workflows Focus on machine learning, not programing Integrated best practices Model validation tools built into app Rich documentation with step by step guidance Flexible architecture for customized workflows Complete machine learning platform 21
Key Takeaways Consider Machine Learning when: Hand written rules and equations are too complex Face recognition, speech recognition, recognizing patterns Rules of a task are constantly changing Fraud detection from transactions, anomaly in sensor data Nature of the data changes and the program needs to adapt Automated trading, energy demand forecasting, predicting shopping trends MATLAB for Machine Learning 22
Additional Resources Documentation: Machine Learning with MATLAB: 23
Q & A Topic of interest Working with IoT data Accessing, analysing and visualising data Working with big data sets Deploying machine learning algorithms Machine learning with computer vision Session / Demo Station Session: MATLAB and the Internet of Things (IoT): Collecting and Analysing IoT Data Session: Analysis of Experimental and Test Data Session: Tackling Big Data with MATLAB Demo: Building MATLAB Apps to Visualise Complex Data Demo: Identification of Objects in Real-Time Video 24