In today’s post, we will use the model we trained in 15 minutes or less to predict whether someone has diabetes or not. And we are going to do that in 7 lines of code. I advise you read the post as there are some references to it below which will help you better understand what we’re doing.
You can use the trained model generated as part of the other post or you can download it here.
This time I will straight out of the bat just hand you the code:
If you run it as is, assuming you have the “diabetes.h5” file placed in the same folder, you should get a “1.0”, what that is is a prediction that the person described in line 7, does have diabetes. You can play around with the number and see the system behaves.
Since the CSV contains the actual information as to whether the person has diabetes or not, you could pick – for instance – the person described on line 601 (1,108,88,19,0,27.1,0.400,24), who we know doesn’t have diabetes and use that to tweak the values on line 7 and check if the system can predict the result correctly.
And if you are using the same model as me, it will predict correctly that the person does not have diabetes. Then you can try person from line 604 (7,150,78,29,126,35.2,0.692,54) who does have diabetes.
False negative! Not as accurate huh?!
Well, even doctors get it wrong…
Shall we try another one? How about person from line 747 (1,147,94,41,0,49.3,0.358,27)?
AAAAND it works!
But now you are doubting the accuracy of this thing, right? Well, we only fed it with data from 600 people, it’s known that the more data you put in, the more accurate it becomes, but how accurate, exactly it is right now? You can use the code below to find out:
In this case, the accuracy will be of 83.20%. Not perfect but also not bad huh?
What is next?
You can try adding more (or reducing) hidden layers, playing with the number of nodes, or modifying the activation function and seeing how that affects the accuracy of your model.
If you want to reach the next level and learn how to train your model using supervised learning techniques, I recommend getting my ebook Deep Learning for Developers, it’s free if you have a Kindle account and quite cheap if you don’t.