Predictive Analytics with ModelArts

Muhammet Berke OZTURK
Huawei Developers
Published in
5 min readMay 16, 2023

In this article I will try to explain how to use Huawei Cloud ModelArts Service for Predictive Analytics and make a demonstration about it. Let’s hop on to it.

Introduction

Predictive Analytics is a AI modeling service for Huawei Cloud that you can use it for predictions about future outcomes using historical data combined with machine learning.

For example you can use it for predicting if a patient has diabetes or not. Or for example you are going to sell your car and you don’t know how much money you should sell it for. You can use it for predicting your own car’s price with a dataset of car informations.

Let’s start with a demonstration of diabetes example.

Predictive Analytics with ModelArts Demonstration

At the below there is the lifecycle of a predictive analytics. We are going to follow that cycle. First we are going to find or create a dataset for ourselves. After that we are going to prepare the data for training. Like cutting the nonsense values from dataset. Now we will start the training from Predictive Analytics service on ModelArts. If we have a good training results and metrics we can deploy and try that model for our purposes.

Predictive Analytics Lifecycle

First we need a dataset to teach our model how to predict. So we can use some websites like Kaggle.com or Github.com. If you want a unique dataset, you can create your own dataset of course. But for this example we are going to use a public dataset of diabetes patients from kaggle.com. This is the dataset we are going to use it for our custom predictive analytics model for diabetes detection. There is some datas about the patients which are diabetes or not. We have the metrics that they have already such as Skin Thickness, BMI or Age. With these datas, model is going to predict if patient is diabetes or not.

Diabetes dataset in CSV format

The dataset must be in CSV format to use it in ModelArts, ExeML Predictive Analytics. Caution on that…

After that we create a OBS Bucket for our dataset on Huawei Cloud.

Creating bucket in Huawei Cloud OBS

Uploading our dataset to our OBS Bucket.

Uploading dataset in OBS(1)
Uploading dataset in OBS(2)

After the upload is complete we can hop in to ModelArts service.

In the ModelArts Service page we choose ExeML from the left bar.

ModelArts Service ExeML

There is some training types here. We choose Predictive Analytics for this demonstration.

Predictive Analytics Service

Here we are creating our Predictive Analytics job. Give it a name and description. Choose the CSV file that you upload for your predictive analytics model from file browser on your OBS Bucket.

Creating a project
Selecting the dataset we uploaded

Now we need to select the data for prediction. Predictive Analytics page automaticly creates a table on the browser from your CSV file. Select the attribute you want the model predict for Label Column(attr_9). If you are training a model that it’s going to predict yes or no datas. Select Discrete Value. If you are going to train a model which is going to predict a variable value select Continuous Value. For our model it’s Discrete Value because we want to predict a patient’s diabetes state. Yes or No. Click train after.

Giving the metrics for training

Here the training started. We can see our version of model here.

Training process

After the training is finished, this is the page you are going to see. You can check the evaluation result metrics. Click deploy after.

Training process complete and metric results

Deployment is pay per use so i suggest you to select auto stop after 1 hour.

Deploying the model

After deployment you can try your model with a JSON file from Prediction section. The JSON file syntax and test datas are given below. You need to let blank the attribute you want model to predict. Other attributes must be filled. We have a test data to test our model after deployment. Let’s test it on our model.

Test datas
{
"data":
{
"count":1,
"req_data":
[
{
"attr_1":"3",
"attr_2":"111",
"attr_3":"90",
"attr_4":"12",
"attr_5":"78",
"attr_6":"28.4",
"attr_7":"0.495",
"attr_8":"29",
"attr_9":""
}
]
}
}

Here we are. At the return result there is a predict value. This is the value that our model predicted for attribute we want to predicted. We predicted the test data of a patient which is not a diabetes and predictive analytics of ours predicted right!

Testing the model(2)

Let’s give it another try. This time we give it the datas of a diabetes patient.

Testing the model(2)

It predicted right again.

Final thoughts and Summary

So in this demo article we tried to train a predictive analytics model for predicting if patients diabetes or not. So far so good our model is working great. You can check the Huawei Cloud and train models like this and use it for your own projects. This service is a really good start to learn basics of Machine Learning and Artifical Intelligence. Give it a try!!

References

--

--