# Day 1: MATLAB Platform and Data Analytics

## Introduction and Welcome - Andy Grace

Session Q\&A slots: <http://community.thingspeak.com/feedback> *Enter*: first name, last name, comapny: comment/question

Text: (508) 433-3693

R2017b Pre-Release coming week of June 12, 2017

## MATLAB Keynote - Roy Lurie

* MATLAB is designed for engineers and scientists, not a general purpose programming system
* MATLAB has apps for interactive exploration, and automated code generation for deployment on production systems
* MATLAB makes data science easy and accessible for Engineers and Scientists
* MATLAB Strategy Highlights
  * Live Editor
    * Good for algorithm exploration and publishing
    * Not just a place code runs, but a place to tell the story of what is happening
  * App Designer
    * Catching up to GUIDE
    * No comment about sluggish performance for even modest sized apps
  * Engineering Data Analytics
    * JSON
    * Tall arrays
    * Big data algorithms
    * Spark (and Hadoop) integration
  * Deep Learning
    * Existing deep learning tools are for programmers
    * MATLAB makes deep learning easy and accessible for Engineers
      * net = alexnet;
        * An already trained network readily available for download
    * R2017b is a major release for Deep Learning
      * World-Class Prediction Performance
        * CUA compiled with GPU coder
        * Much faster than TensorFlow and Caffe
      * New Algorithms
        * Image segmentation analysis is easier to do now
  * MATLAB makes Internet of Things easy and accessible fo Engineers and Scientists
    * New application called ThingSpeak
  * Online offerings
    * MatWorks cloud ecosystem is complete in 2017
      * MATLAB Drive
        * Akin to Microsoft Live, DropBox, Google Drive
      * MATLAB Online
        * Available to all named users
      * Mobile editor

## MATLAB Platform Experience - Loren Dean

* MATLAB Platform
  * 2015 - Architecture
  * 2016 - Design Points
  * 2017 - Workflows
    * Individual Workflow
      * Personal code
      * Single discpline
      * Single desktop or small cluster
    * Team Workflow
      * Multidisciplinary work
        * Engineering domain
        * Job function (IT, DevOps, ...)
      * Servers and databases
        * CI Server
        * Cloud
        * Large cluster
        * Databases
        * Data marts
        * Production system
    * Value Drivers in MATLAB similar to model-based design in Simulink
    * MathWorks Cloud Framework
      * Questions revolving around Amazon Web Services (AWS) / Microsoft Azure
        * Cloud Center is used to spin up a cluser on AWS

### MATLAB Code Development Tools - John Glass

* Live Editor
  * Creating Live Scripts
    * Equation Editor (R2016b)
    * Interactive Plots (R2016b/R2017a)
    * Editable Figures (R2016b/R2017a)
    * Functions in Scripts (R2016b)
      * Also available in plain-text editor
    * Function Assistance (R2017b)
    * Evaluation is faster, typing is smoother in R2017b
      * Auto and graphical merge

### MATLAB Language - Dave Foti

* Simplifying common programmint tasks
  * String Arrays (R2016b)
  * Library of new functions for string manipulation (R2016b)
  * Use of strings with double quotes (R2017a)
  * New cell array display (R2017b)
  * No file left behind (R2017b)
    * New help tip for adding a path to a file that isn't yet visible
* Simplifying class and function authoring
  * Object property validation (R2017a)
    * Declaration properties
    * Function input arguments
    * Define multiple functions with different argument signatures
  * Defining code modules
    * Define interfaces
      * Not worry about helper functions being on the path
    * Defining dependencies
* Connecting with other langauges
  * Interfaces
    * Use libraries from inside MATLAB
  * Engine
    * Embed MATLAB as a computation engine
  * C++
    * Building out C++ Engine API in R2017b
  * HTTP and RESTful web services
    * jsonencode and jsondecode (R2016b)

### MATLAB Performance, Code Compatibility, and Code Testing - Vadim Teverovsky

* Performance Update
  * R2017b Examples:
    * Support for AVX2 instructions
    * Improved performance of small arrays
    * Imrpoved try/catch performance
  * Faster MATLAB Startup after reboot on a representative machine
    * 39 sec (R2016a) -> 24.5 sec (R2016b) -> 14.5 sec (R2017a)
* Upgrading to a New Release
  * Read release notes for potential issues
    * R2017a
      * Grouped by category
      * Can filter by incompatibility
  * Find these issues in your code (MAB 2016: The most time-consuming step)
    * R2017b
      * MATLAB Code Compatibility Report
        * Detect potential incompatibilities
  * Figure out how to update your code
  * Update your code
  * Test updated code
* MATLAB Code Testing
  * Unit Testing
    * Unit Testing allows you to lock down the behavior of your code
    * Scales from simple to large-scale testing
    * Framework
      * Easy creation and execution of your tests
        * Write tests as scripts, functions, or classes
        * Industry-standard xUnit style
      * R2017b
        * Integration into Live Script
  * Performance Testing
  * Mocking Framework
    * R2017a
    * Isolate a portion of a system to test by imitating behavior of dependencies
  * App Testing Framework
    * App Designer apps only

### Scaling MATLAB Applications from Desktop to HPC - Jos Martin

* Context for Scalability
  * Problem Sizes Grow
  * What to do?
    * More Machines
      * More system complexity
* Scaling Data
  * Big data, GPU, Deep Learning
  * Datatypes
    * tall / Disks / Pre-processing, statistics, machine learning
    * distributed / Cluster / Sparse and dense numerics
    * gpuArray
  * GPU-Accelerated Deep Learning
    * R2017b - CPU Coder
  * Set training options to specify multi-gpu/parallel
* Scaling Compute
  * Standard method: parfor & parfeval
  * R2017a - Interactive Parallel Programming
    * Problem:
      * You have a long running paralle program
    * Solution: DataQueue
  * Options
    * Parallel Computing Toolbox
    * MATLAB Parallel Cloud
    * Cloud Center
      * Virtual Private Cloud Support
      * GPU Clusters (P2)
    * Custom Cloud
    * MATLAB Distributed Computing Cluster
* Scaling Simulink Workflows
  * Running many simulations
    * Traditional method: parfor + sim
    * New parsim in R2017a
      * Setup simulation inputs
      * Run simulation in parallel using parsim
    * R2017b
      * Live streaming of simulation results in Simulation Data Inspector
      * Simulation Manager

### Deploying MATLAB Code in Embedded Systems - Fred Smith

* MATLAB Coder - The Most Interesting App in the World
  * Generates embeddable C code
    * ANSI C
  * Trend
    * Performance
      * GPU
      * SIMD
      * Multi-core
    * Algorithms
      * Machine Learning
      * Computer Vision
    * Integration
      * OpenCV
      * AUTOSAR
      * Your code
  * R2017a
    * Algorithms: Dynamic memory allocation
    * Performance: Loop invariant code motion
    * Performance; Fast FFT
  * R2017b
    * Performace: CPU Coder
      * Utilizes code for fast deep learning performance

### Deploying MATLAB Code for Production Use - Jim Stewart

* Application deployment
  * Share code with other MATLAB users
    * Create your toolboxes and share with others using Toolbox Packaging
      * Package toolboxes as a single installer file
      * Automatic inclusion of dependencies
  * Share code with non-MATLAB users
    * Package code as
      * Standaline executables
      * Excel add-ins
      * Big Data applications using MATLAB compiler
    * Integrate with
      * Applications written in other languages
    * MATLAB Compiler and MATLAB Compiler SDK
    * Deploy App Designer Web Apps on Intranet
      * Beta program in R2017a/R2017b
      * Provide a web-app server that can be installed on internal network
    * Deploy Big Data Applications
      * Apache Spark (R2016b)
  * Deploy into production systems with MATLAB Production Server
    * Deploy updates without server restarts
    * Downloadable Performance report (R2017a)
    * IT admins manage software using Dashboard (R2017a)
    * Operationalize your MATLAB analytics
    * Availability of Cloud Formation Scripts for AWS and Azure (R2017a)
  * MATLAB client for MATLAB Production Server
    * Algorithm and version management

### Harware and Analytics in the IoT Workflow - Rob Purser

* Pull it all together
  * IoT Challenges:
    * New technologies
      * Sensor analytics, cloud, machine learning, and more
  * Multidisciplinary teams
    * Engineers, solution architects, IT, DevOps, and more
  * Software in multiple places
    * Embedded, in the cloud, on desktops, in browser
  * Steps to pulling it all together
    * Start with an idea...Explore using MATLAB
      * Pysics-based models
      * Collect test data
        * Data acquisition and instrumentation
        * Cmaeras
    * Refine your idea with your team
      * Transform your idea to algorithm
    * Prototype with hardware
      * Code generation from MATLAB and Simulink
    * Validate with multiple IoT devices
      * Analytic IoT Platform
        * ThingSpeak
          * TMW's IoT analytic platform (R2015a)
            * Collect
            * Analyze
            * Act
    * Develop production online analytics
      * Can deploy algorithm to ThingSpeak, instead of running locally
    * Go to Production or Scale Up
  * Tools
    * Predictive Maintenance Toolbox
    * Sensor Fusion and Tracking Toolbox (R2017b)

## MATLAB Data Analytics - Mary Ann Freeman

* Predictive Maintenance
  * Modeling
    * First principles modeling
      * Physical models
      * Kalman filters
    * Data-drive modeling
      * Curve fitting
      * Machine learning
  * Generate failure data using Simulink
  * Features
    * Access data with readtable, datastore (R2016b)
    * Preprocessing with timetable, tall (R2017a)
    * Work with Simulink logged output (R2017a)
    * Explore graphically (R2017a)
    * Machine learning models (R2017b)
* Deep Learning
  * Deep learning is a neural network that learns directly from the data
    * Deep learning model can extract features automatically to classify objects
    * Deep learning is transforming machine learning
      * Data
        * Computer vision, text, and speech
        * Recognition fields revolutionized
      * Key projects
        * Tensorflow, caffe, et al
      * Issue
        * Difficult to learn and apply
  * Deep learning enablers
    * Massive sets of labeled data
    * Acceleration with GPUs
* Topics to come
  * Data handling: time-stamped & big data
  * Deep learning & machine learning
  * App building & web apps

### Time-Stampled Data Handling with Timetables - Nick Haddad

* timetable overview (R2016b)
  * Used in accessing and exploring & analysis
  * `table2timetable`
  * timetable flows seemlessly in functions such as
    * `rmmissing`
    * `filloutliers`
    * `smoothdata`
  * `synchronize` is used to synchronize data
  * Import timetable into Simulation Data Inspector (R2017b)
  * Signal Analyzer App (R2017a)
* Comparision with timeseries
  * timeseries
  * timetable
* timetable Roadmap
  * MATLAB end-toend workflows
  * Adoption across products
  * Collections
  * Events
  * Time-based preprocessing
  * Visulization

### Big Data Handling with Tall Arrays - Penny Anderson

* Tall Arrays through R2017b
  * Overviews
    * Gives capability to work with data that doesn't otherwise fit in the computing machine's memory
    * Introduced in R2016b
    * Ideal for tabular/columnar data
    * Overall data size is too big to fit into memory
  * Functions specific to Tall Arrays
    * Access data with `datastore` and `tall`
    * Calculat statistics using `gather`
* Roadmap for Tall Arrays
  * `synchronize` will work with Tall Arrays
  * ThingSpeak
  * Access: Write your own datastore (R2017b)
  * Machine Learning with Tall Arrays
    * R2016b
      * kmeans
      * fitlm
      * fitglm
      * fitcdiscr
      * cvpartition
    * R2017a
      * fitclinear
      * fitcnb

### Machine Learning & Deep Learning with MATLAB - Jon Cherrie

* Deep Learning with MATLAB
  * Pre-trained network: `net = alexnet;`
  * Inspect the network: `net.Layers;`
* Topics
  * Easy to develop systems with machine learning & deep learning
    * Developing predictive models
      * Apps
        * Ground Truth Labeler (R2017a - Automated Driving System Toolbox)
        * Classification Learner (R2015a - Statistics and Machine Learning Toolbox)
        * Regression Learner (R2017a - Statics and Machine Learning Toolbox)
      * Model Optimization
        * Bayesian Optimization now built into many functions natively
      * Access to the Latest Research
        * Reference models
          * AlexNet, VGG-16, VGG-19
          * TensorFlow importer in the works
        * Caffe model importer
      * Deployment
  * Accessiclbe to non-experts
    * Tutorials - Deep Learning in 11-lines of MATLAB Code
  * High perfromance embedded implementation
    * Code generation workflow
      * Train your model
      * Implement a wrapper function
      * Generate code
    * Support for predictive models
      * R2017b
        * fitcdiscr
        * fitcknn
        * fitrsvm
        * fitrensemble
        * fitrgp

### Text Analytics: Deriving Information from Text Data - Ben Hinkle

* New product
  * Text Analytics Toolbox (R2017b)
    * `extractFileText`
    * `eraseTags`
    * `removeWords`
    * `bagOfWords`
    * `predict`
* Applications
  * Document classification
    * Field reports
    * Bug reports
  * Sentiment analysis
    * Survey data
    * Trial notes
    * Social media
  * Predictive maintenance
    * Equipment log notes
    * Combine notes with numerica data

### Deep Learning Deployment on FPGAs, CPUs, and GPUs - Girish Venkataramani

* Deep learning workflow
  * Training
    * Definte network
    * Injest data
  * Deployment
    * Challenges
      * Fitting on embedded
        * Research DNNs are general
        * Application-specific DNN can be tailored to be much smaller
          * Re-architect network > weight compression > quantization to FP16, INT8
      * Scale performance on the platform of choice
        * NVIDIA GPU
          * R2017a
            * 14x faster than Caffe
            * 4x faster than TensorFlow
        * A deep learning (DL) coder infrastructure
          * GPU Coder > CUDA code (R2017b)

### App Building Advancements and Web Apps - Chris Portal

* Feedback (2014-2016)
  * Components
    * Parity with GUIDe
    * More Components + Richer Configurations
      * Layout Management
  * App Sharing
    * Run apps on Mobile and Browser platforms
  * App Designer
    * Resources for GUIDE to App Designer migration
* Developments
  * Components
    * R2017a
      * Graphics Pan & Zoom
    * R2017b
      * 3D Plotting (App Designer)
      * UIMENU (App Designer)
      * UITREE (MATLAB Interface)
  * Graphics
    * R2017a
      * Heatmap
    * R2017b
      * Tall plot
  * Moving to the Web
    * End goal is targeting web-based dashboards and data-centric apps
    * Extending MATLAB platform across MATLAB Online & MATLAB Drive (R2017b)

### Migrating GUIDE Work to App Designer - Jyoti Gandhe

* Resources being developed to automate current workflow
  * `fig2mlapp()`
* Migration workflow
  * Migrate Components & Callbacks (will be automated)
    * Lay out components
    * Configure component properties
    * Tag components with names
    * Wire callbacks to callback functions
    * Copy callback functions over
  * Update Code (will remain a manual process)
    * Use App Designer style code
    * Reconcile component API differences
    * Run migrated app to validate/troubleshoot
* Roadmap
  * Migration tool will be available as an R2017b add-on

## Breakout Sessions

### MATLAB Testing: Frameworks and Workflows - Andy Campbell

* TMW Developer Blog: blogs.mathworks.com
* Visit their tech showcase for examples and demo of workflow
* Unit test framework
  * Script-based/ function-based, class-based
    * TMW encourags exploration of script-based tests
* Performance test framework
* App test framework
* Mocking framework

#### Continuous integration - Andy Campbell

* Most users in the session are using Jenkins
  * Go to the blog about continuous integration
* Integrations
  * TAPPlugin (Original format)
  * XMLPlugin (Junit format)
  * TAPPlugin (Version 13)
  * TestReportPlugin (html)
  * CodeCoveragePlugin (Cobertura output)
* Support package for Jenkins
* Streamlining online, cloud, etc
* Simulink test support
  * Simulink Coverage

#### Typical workflow - Stephen Carter

* Write > Run > Analyze
  * Write
    * Class-based, function-based, script-based
    * Live script compatibility (R2017b+)
    * Artifacts
      * FigureDiagnostic (R2017a)
      * ScreenshotDiagnostic (R2017a)
      * `testCase.onFailure(@() doSomething())` convenience (R2017b)
  * Run
    * Formal interface (TestRunner)
  * Analyze
    * `results = runner.run(suite); results(1).Details.DiagnosticRecord` (R2016a)
    * HTML test report (R2017b)

#### Extensions & Plugins- David Hrushka

* Extensions
  * Plugin output streams
  * Constraints & Tolerances
  * Fixtures
  * Diagnostics
* Test Suite Hierarchy
* Data Drive Testing

#### Mocking Framework - David Hrushka

* Shipping since R2017ag
  * `testCase.createMock(?Pet);`

#### App Designer Test Tools - Steve McClure

* Driving your app
  * Only works with human interaction, not programmatically modifying controls
  * Programmatic gestures
    * Press
    * Choose
    * Drag
    * Type
  * Guiding principles
    * Support testing interactions for what App-authors can do
      * Boost your code coverage
    * Realistic Gestures
      * Eg, respecting z-ordering
    * Isolate the App Under Test
      * App is locked out during tests
    * Interface Philosophy
      * Leveare a small set of functions with common and intuitive APIs
      * Emphasize the App-*User* rather than the App-*Author*

#### The MATLAB Performance Testing Framework - Andy Campbell

* R2016a
  * `runperf`
  * Fixed time experiment
  * Variable sample time experiment using classical statistics
* R2017a
  * Sample summary
  * Leverages the new `samplefun` function
* R2017b
  * Multiple measurement points
    * `testCase.startMeasuring;`
    * `testCase.stopMeasureing;`

### Upgrading to the Current Release: MATLAB, Simulink, and Code Generation - Narfi Stefansson/Richard Adame

* Release Compatibility
  * Good internal MathWorks processes
    * Understand and reduce customer impact
    * Make chages deliberately
  * Tooling
    * Understand what changed in a release
    * Find the affected artifacts (code/models/files/...)
  * Documentation
    * Document product changes
    * Provide information on how to migrate affected artifacts
  * Test frameworks
    * Know that all changes have been addressed
* Documentation
  * Release notes can now filter by range of releases
  * Release notes provide summary
  * Explain Differences between functions that are no longer recommended
  * Release Notes are concise
  * Migration documentation should describe:
    * Motivation for change
    * Functionality differences
    * How to update code/model/...
  * Should be accessible after original functionality has been removed
  * White-paper from TMW with all they know about upgrading
* Upgrading MATLAB Code
  * Finding specific places where code changes are needed
    * Code Compatilibity Report (R2017b)
      * Analyzes your MATLAB codebase
      * Performs \~300 checks to locate incompatibilities
      * Creates report with recommendations
      * Also has a command-line version for integration with scripts
* Simulink Upgrade Advisor
  * R2016b has a command-line API for automation of upgrade
  * R2017a can upgrade all models in a Simulink Project
  * R2017b has better handling of library blocks
  * Simulink Project Provides Encapsulation
* Re-Using Generated Code
  * Production code integration across releases is a barrier to upgrading
    * Typical upgrade approaches
      * Manual integration: Difficult
        * Duplicate utilities
        * Non-functional changes
        * Large number of utilities
      * Generate new code for all components: costly re-verification
    * Automatically reuse previously verified code in new releases
      * Avoids re-verification of components
      * System-level integration
      * R2016b
        * Reuse existing shared code
          * Avoid generating duplicate utilities
          * Reduce integration merging
        * Automatically integrate model code
          * Import code from previous releases back to R2010a
        * Generate efficient integrated code
          * Cross-release code generation
  * Presentation - Day 3, Thursday Morning, 8:30am
    * Code Generation and Targeting Session
