Running MATLAB Machine Learning Jobs in Amazon SageMaker - MATLAB
Video Player is loading.
Current Time 0:00
Duration 23:09
Loaded: 0%
Stream Type LIVE
Remaining Time 23:09
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 23:09

    Running MATLAB Machine Learning Jobs in Amazon SageMaker

    Dr. Shun Mao, Amazon Web Services

    Amazon SageMaker is a popular AI platform in the cloud providing a broad range of capabilities and services for AI developers. One of the great advantages of SageMaker is that it lets developers run jobs on a wide selection of compute instances, including GPU support with the pay-as-you-go pricing model, without managing underlying infrastructure. Learn how to leverage SageMaker to train a machine learning model using MATLAB®.

    Published: 7 May 2023

    [AUDIO ID]

    Hello, everyone. My name is Gandharv Kasinath. I am the Product Manager for cloud platform integrations at The MathWorks. In my role, I help customers solve their engineering and science problems by using MathWorks products in the cloud. Joining us today is Dr. Shun Mao from AWS. I'll let Shun introduce himself. Shun?

    Thank you, GK. Hi, my name is Shun Mao. I am a Senior Partner Solutions Architect in AI/ML at AWS. I help ISV partners develop their cloud products on AWS and look for opportunities to make AWS and partner's product better together. Thank you.

    Thanks, Shun. So today, we're here to show you how to run MATLAB machine learning jobs in Amazon SageMaker, so let's get things started. Here is our agenda for today. We'll start out the presentation by giving you some context about machine learning. I'll share with you some popular engineering applications of MATLAB and Simulink in machine learning. Shun will then jump in and show you a demo of how MATLAB Docker files and containers can be used to run MATLAB in Amazon SageMaker.

    And we'll conclude with a few SageMaker platform highlights and share with you some of our contact information so that you can get in touch with us to continue this conversation. So let's kick things off, let's talk about machine learning. Machine learning can be used in applications where traditional modeling techniques fall short. Here are some popular use cases in machine learning for engineering and science.

    MATLAB is being used to solve engineering problems in speech and object recognition, engineering health monitoring, and predictive maintenance. Basically, think of applications that require algorithms that can learn non-linear relationships. Models developed in MATLAB can be used to learn quickly from new data. Now, this is almost a requirement for many dynamic systems, like weather and energy forecasting or several financial applications that are currently out there.

    MATLAB's data integration can be used for applications like IoT that require you to work with streaming data. It can also be used for time and space correlation data to develop rideshare applications. Now this typically involves working with large data sets. And when I say large data sets, cloud is increasingly becoming the chosen platform to store large amounts of data securely and access it quite quickly.

    And now, we are also learning that our customers are developing their machine learning models in the cloud and having it all integrated into one unified system. MATLAB offers solutions for all of these applications. Now, considering these applications, we see that a typical machine learning workflow involves these four major steps that you see on the screen. Engineers typically begin by accessing data. Your data could be in Excel files, databases, data from sensors, streaming data.

    Think of platforms like Kafka which are fairly popular in the cloud. It can also be stored. All of this data can be stored in S3 buckets on AWS. Now, MATLAB allows you to work with your data sets, with large amounts of data, and we have a lot of product and support packages that will help you connect to this data and leverage it for your engineering workflows. Most engineering data, as you may already know, is messy. It's not always suitable for training your machine learning models.

    You can pre-process this data and extract features from your raw data that's the most relevant for your model development, and MATLAB allows you to do that. You can then use this data to train and compare machine learning models. You can leverage GPUs, multi-core CPUs on AWCC 2 with MATLAB to speed up your model training jobs. You can do all of this by paying on demand as well. MathWorks silver products let you easily operationalize your models in the cloud, and we have lots of solutions to support our customer workflows in this area.

    Now what I want to do next is I want to take this workflow and apply it to develop a real world machine learning system in the cloud. In order to develop the system, I want to introduce you to this user persona Alex. Alex is an Automation Engineer working in a car manufacturing facility. Alex is tasked with producing a machine learning solution to monitor the health of a cooling system at the facility.

    One of the critical systems is a coolant pump in this cooling system, which has measurements of pressure, flow rate, and motor RPM. The health status of the cooling system is determined from the outputs of these measurements. Now, it is Alex's job to notice any anomalies, and as soon as he notices any anomalies in the system, he needs to take immediate action to keep this cooling system functioning optimally all the time.

    So we are going to develop a machine learning model to help Alex with this workflow. Now Alex can begin developing the machine learning model by modeling the coolant pump in Simulink. The pump model can be used to generate synthetic data for inputs like pressure, flow rate, and motor RPM. The time series data can then be pre-processed to extract features that are most relevant for Alex or for the model that's being developed.

    And then, MATLAB can also be used to label this data with the corresponding fault codes. Remember, each fault code can mean a different thing, and Alex may need to take different actions based on the fault codes that are reported. Now, using this data, Alex can develop and train a machine learning model to predict fault codes, then he can go ahead and pick the best model that fits the application that he is developing.

    Alex can also go out and compare these models with several popular machine learning algorithms that are currently available in MATLAB. We have a whole host of models for supervised and unsupervised learning. In this example, we'll focus on a supervised learning algorithm. Now, next step is to actually make the fault code predictions using actual sensor measurements from the cooling system. Let's see how that can be done. MATLAB really makes it easy to deploy models to the cloud.

    Data from the cooling system can be streamlined and stored directly in the cloud. The deployed MATLAB model can then be used by Alex to monitor the health of the cooling system. Now, in the next section, Shun will walk us through how to set up this workflow in Amazon SageMaker. And Shun's demo will focus on setting up the part of the workflow that we've identified in this blue box. I encourage you to get in touch with us if you want to explore any other parts of this workflow.

    So with that, I'll hand it over to Shun.

    Hi. Today, I'd like to demo how MATLAB and Amazon SageMaker can work together to help solve the cooling system health monitoring problem by training a machine learning model and deploy the model as a real time endpoint. We can follow a typical machine learning workflow. First, we need to prepare and access our input data. The input data we have today is a Simulink-generated data set with numerical predictors from time signal analysis of pump flow with three types of faults possible in eight combinations.

    No fault state is shown with fault status 0. This data has 720 rows in a 14 features, which simulate a sensor signal measurements. The last column is a target, which we need to predict, which represents the possible fault scenario. The data size is very small and fairly simple, but we are mainly focused on integration in a workflow. You can adapt it to your own ML use case and data. Here, we are leveraging Amazon S3 for storing our input data, so I have uploaded this input to my S3 bucket.

    Next, we need to do some pre-processing This is where you can use your favorite MATLAB algorithms and toolboxes to do any pre-processing in a feature engineering. In this demo, I'm just splitting the data into features and target, and also normalize the numerical features. Potentially, if you have large data set or your processing flow is rather complex and takes a long time, you can leverage SageMaker processing jobs to do those calculations.

    SageMaker processing job provides abundant computing resources for you, and you can bring your own processing container and algorithms. But here, since the processing is simple, I will combine the step with the motor training code and use SageMaker training job to do all the calculations. Now, it's time to build a machine learning model. Here, we are building a simple decision tree classification model. Let me run this sale live to give you a feeling how the model training process looks like.

    Here, I have turned on the hyperparameter optimization option to get a better result. The training process kicks off, and soon, I will get a MATLAB model. Let's give it a few more seconds. As we see, the training has finished fairly quickly. And then we get a model in this data set. But if you want to run into four more iterations or you have large model to build, this process can take a long time. Of course, this is all run locally.

    How do we run it in SageMaker and to potentially leverage the wide selection of computer resources out there? The main idea here is to leverage the container technology since SageMaker supports bringing custom view Docker containers to run training jobs. In order to achieve that, we need to build a custom Docker image that it can run MATLAB code. Luckily, since MathWorks has already published quite a few MATLAB images, we can build our image based on those ones to save some time.

    Here's an example Docker file we can build upon. I'm not going into the details of this Docker file today. But I just want to say that it is built based on this public MATLAB image. Once a Docker image is built, we need to push it to MSER ACR. MSER ACR is where you can save your container images that you will need to work with SageMaker and, of course, some other AWS container services. I have prepared the image beforehand and we can check it in each of AWS console, right here.

    It'll provide you a ECR URI, which we're going to need later. After that, we can create a SageMaker session and give the execution role to SageMaker, then supply the necessary parameters that we will pass to the SageMaker training job. The key parameters here are the training image URI, the training function, and the training instance sites. The training function has been defined in the bottom of this live script.

    It has very minimum changes, mostly on the input path and output paths definition. The rest of the code remained the same. With that done, we can create a SageMaker estimator, and then call the fit method. When we run this line, it fires up a SageMaker training job. It may take some time depending on your data size and amount of complexity. To save time, I've already run it beforehand. Here's how it looks in a speech maker console.

    Here, I have a bunch of SageMaker training dogs run before. When you clicked the training job, SageMaker provides you all the details of the job. Also, you can check the job logs in Database Cloud Watch for debugging purposes. Once the job finishes, we can see the model has been saved into the S3 bucket. Again, here, we are leveraging S3 to save the model file. Now we finish the training and get the MATLAB model.

    How about hosting the model as a SageMaker endpoint? Let me jump back to MATLAB to show it. Simply call the deploy method and it will prepare the endpoint configuration and deploy the model as a real time endpoint. This is where you can select the instance size where you want to host your model depending on the model size. We can verify the endpoint in the console as well. I'm going to the Inference tab then click the endpoints, and the endpoint is in service.

    It's as simple as that. And you can delete the endpoint anytime you want to save cost. Next, we can supply some test data set to test the endpoint. Here, I'm giving the endpoint 10 records to test. If I run this right now-- let me run it. We're seeing the inference result from the end point successfully. Now we have completed the flow.

    And this model endpoint can eventually be called by any application you might have with standard API call, so that it can help your organization improve your predictive maintenance. I hope this demo is useful, and I would love to see how you will leverage SageMaker to run your MATLAB workload. Feel free to connect with AWS and The MathWorks to enable this workflow. Thank you so much for your attention.

    Now, with that demo done, here I would like to talk about how Amazon SageMaker can help enterprises and startups adopt AI and machine learning faster and easier. Amazon SageMaker is a comprehensive machine learning platform enabling various personas to view, train, and deploy machine learning models for virtually any use case, regardless of their machine learning expertise. Here, I have listed some of the most popular use cases that AWS customers are working on by leveraging SageMaker.

    But there are literally hundreds of them, which we don't have time to go through today. To pick a few, for example, predictive containers, we have Georgia-Pacific, who uses SageMaker to develop a mail models that detect machine issues early. For credit risk prediction, we have Fannie Mae, who utilizes SageMaker to develop, evaluate, expand, and improve the models used in everything from assessing the loans it backs to analysis of property values.

    And we all hear about autonomous driving. In that area, we have company Aurora, who uses SageMaker to safely and quickly train, test, and validate its self-driving vehicle technology and reduce the model training times from days to under a couple of hours. So, so many interesting projects are being worked on across all sizes of companies that are leveraging SageMaker. Today, there are tens of thousands of customers using Amazon SageMaker, making it one of the fastest growing services in the history of the AWS.

    Now let's see what has attracted so many customers to use SageMaker. Basically, SageMaker has provided so many features at every step of the machine learning workflow from end to end, and the ecosystem is still expanding rapidly. Here, I have only highlighted a few key features due to the length of this presentation. For example, in data preparation, SageMaker provides Data Wrangler for no coders to explore and process data.

    Also, we know that feature quality for machine learning models is extremely important. Many features are used repeatedly by multiple teams SageMaker feature store is a fully-managed, purpose-built repository to store, share, and image features with machine learning models. For data processing, SageMaker provides studio notebook and notebook instances for fast and easy experimentation.

    Moreover, SageMaker processing allows customers to run their own processing algorithms by leveraging container technology and the abundant computing resources that it AWS provides. For model training, SageMaker has done the heavy lifting by creating a fully matched training environment. It also supports distributed training and support training to improve the performance and the cost. For model hosting, SageMaker offers flexible hosting patterns, such as real time, serverless, asynchronous, and batch mode. Serving different purposes.

    Obviously, each service and a feature are worth at least an hour to talk about. Unfortunately, we don't have time here. So if you are interested in getting started with SageMaker, feel free to reach out to me or any other AWS AI/ML SAs. Now back to GK.

    Thank you, Shun. So let's conclude the presentation. What we saw today, you're all familiar with MATLAB. It's the best in class machine learning tool for engineering systems. We spoke about Amazon SageMaker, which is a go-to platform for many ML and data use cases.

    What I want to emphasize here is that Amazon SageMaker gives you seamless access to store large volumes of data, which can be used for your engineering applications, and also gives you access to use on demand compute resources in the cloud so that you're optimizing your costs and spinning up resources as and when you need it for running your machine learning algorithms. MATLAB can be well integrated into this ecosystem using our container and Docker container offerings.

    And in the demo, Shun showed you how we can leverage Docker files and our containers to run MATLAB in SageMaker. We covered the entire machine learning workflow, and then we also have several bits, other bits, of the machine learning workflow that can be supported on this platform. And like Shun suggested, we encourage you to get in touch with us if you're interested in exploring SageMaker for any of your workflows or use cases.

    We are more than happy to help you and provide support for you to start up for your machine learning jobs on SageMaker. What I've done here is I've included a few contact details. If you want to send us an email at cloud@matchworks.com to explore how you can leverage this workflow, please do send us an email. We are happy to respond back to you and work with you to support your workflow. I've also included our personal email IDs in the QR codes that you see here on the screen.

    Feel free to shoot us an email. We're there to help you out. So with that, I'd like to thank you for attending today's session on running MATLAB in Amazon SageMaker. I hope you all have a wonderful Expo. Thank you.

    Thank you.

    [AUDIO ID]

    View more related videos