DEV Community

spiritupbro
spiritupbro

Posted on • Updated on

IBM Auto AI Predict Early Stage Diabetes - Part 2

Get the data for our machine learning model

So in order for us to create a machine learning model first we need some data, the data that we need to have is data that has an output out of it for example :

age blood sugar level class
10 10 mg yes
27 12 mg no
50 9 mg yes

As you can see above is some example data that we want, it has the data to determine whether or not this people has diabetes or no, as you can see there is age data, blood sugar level data, and class data from the example above, we can see that class data is used for determining whether or not this people has some diabetes or no and the other data is for the input data, so the data that we need is a data that have input and output like that, for the example above, age and blood sugar is the input, and class is the output to determine whether or no we had some early stage diabetes.

So to get this data we can go to some website like https://www.kaggle.com/ here you can see so many free data that you can use, we will use this data by ishandutta that collect the data from some patients in bangladesh[1], this is exactly the data that we need, because it has some input data and also the output data


some example data of diabetes early stage risk

Import the data to IBM Auto AI

So in order for us to get some prediction to our data we need some tools to make it easy for us to do that, luckily IBM create some tools called IBM Auto AI, using this you can create machine learning easily and you can get the data as a web service as well so easily, now go to this link and login with your IBM ID and password, after you login click on view all project like below :

view all project

Click on new project and click on create an empty project :

new project

Fill in the project name and if you want you can fill in the project description, it's optional, you can leave it blank, after that click create :

project name

Select the Settings tab.

project name

Scroll down to the Associated services section. If there is no machine learning service, click Add services, select Watson

click service

Then select Machine learning and click add.

machine learning

Scroll down and select the lite plan then click Create.

create

You're successfully create a watson machine learning service, if there is a success message like this :

success

After we add watson machine learning service now we need to add the data that we want to predict, download the data from here, then after downloading, you will get archive.zip which inside of it you will get diabetes_data_upload.csv, Now let's go back to IBM watson studio and click on assets, and upload the data

click assets

You will then get the data uploaded like this :

uploaded

After that check the data that you uploaded before, then click add to project then also click AutoAI Experiment

auto ai experiment

If you haven't associate your project with the watson machine learning service click Associate a Machine Learning service instance and click reload after you associate it

machine

After you associate it, it will look like this :

associate

And after that, click create, then you need to add data source, click Select from project and click our dataset that we create earlier then click select asset

dataset

After that we need to add prediction column, we gonna click column named class because this column determine whether or not our patient get diabetes based on some data on the left column

pick prediction column

If you click on experiment settings

experiment setting

You can also remove some feature that you think you don't need but for now let's use any of the column

After that click run experiment, and wait for it to be done

wait

After it's done you can see that ExtraTreesClassifier is picked, with accuracy of 0.933 the best out of other pipeline with some enhancements

extra

After that you can also save the code to jupyter notebook by clicking Save code

save

And if you want to see your jupyter notebook, go to assets and click the file in the notebook section

alt text

Then after that we need to create model, in order to do that we need to click Save as click Model then click Create, this model will be used to predict if we got early risk diabetes or no

model

Then after we create our model we need to deploy it as a web service so any platform can call it from the web. Now go to your newly created model and click on Promote to Deployment space

alt text

After that click on new space because we don't have any space yet

alt text

Fill in the name and click create

alt text

Our newly target space will be automatically selected, then after that click Promote

alt text

You will get redirected to your project homepage click on the deployment space hyperlink

alt text

When you click on deploy it will say there is no machine learning service associated with this space

space

Click on Go to space settings

alt text

Click on associate instance

alt text

Then select your machine learning instance, in this case my machine learning instance name is Machine Learning-wr

alt text

After that click on assets again, then click deploy again

alt text

Click deployment type online and named it diabetes deploy or whatever name you want then click create

alt text

Refresh the page and click deployments and you can see that your deployment is still in progress, we will wait until it's complete

wait

After it getting deployed it will showed like this

alt text

We can now try to test our machine learning model is it gonna output the same as in the csv or no,in order to do that click on diabetes deploy hyperlink then click on test

alt text

We can see that our input is exactly like what we have in csv and the output is our class column to determine whether or not we are in an early stage of diabetes let's input first data one by one we gonna input this data below, and the input should be Positive which mean we are in the early stage of diabetes

alt text

After we added our input data click add to list

alt text

After that click on Predict and we can see the result is Positive which mean our machine learning model accuracy is great

alt text

Now we can move forward and connect our machine learning model to web application in part 3

Top comments (0)