Create A Neural Network That Classifies Diabetes Risk In 15 Lines of Python




[ad_1]

Learn about neural network models, and build a neural network in 15 lines of Python with Keras to predict health risks.
Join the community on Discord: https://discordapp.com/invite/QZd3aaN
EDIT 1/13/2019 : Yo guys! I’ve made a few mistakes in my explanation here, and have the corrections and reasoning behind them at the bottom of the description, please check them out. Thanks as always for your support!

► 1:1 Mentorship: https://goo.gl/P3PgC2
► Subscribe To My New Artificial Intelligence Newsletter! https://goo.gl/qz1xeZ

Dataset: http://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data
About the Dataset: https://archive.ics.uci.edu/ml/datasets/pima+indians+diabetes
Keras Docs: https://keras.io/
Code: https://github.com/jg-fisher/diabetesNeuralNetwork

— Highly recommended for theoretical and applied ML —
Deep Learning: https://amzn.to/2LomU4y
Hands on Machine Learning: https://amzn.to/2JSxhIv

Your invitation to our new Slack group: https://goo.gl/dbpgZR

Thanks for watching guys, hope you enjoyed. Be sure to leave any comments or questions below, and thumbs up and subscribe if you enjoyed this video!

___________________________________________________________________

IMPORTANT – I did not split the data into train and test segments. This is necessary in order to assess how well your model generalizes. The training set is the data that your models fits, or optimizes its parameters in order to approximate the mapping between the input vectors X and output (distribution of probabilities in this case Y). The test set data that the model has not seen, and is used to evaluate the performance of the model for its use.

In order to do this a function from the sklearn module can be used called train_test_split.

Add the following lines of code:

from sklearn.model_selection import train_test_split

# after X and Y have been read from the csv
x_train, y_train, x_test, y_test = train_test_split(X, Y, test_size=.5, random_state=5)

# change model.fit to the following
model.fit(x_train, y_train, epochs=1000, batch_size=10, validation_data=(x_test, y_test)

IMPORTANT – epochs are composed of batches, which are each subsets of the data distribution. Over the course of 1 epoch, each batch is forward propagated through the network to get the predictions, and backpropagation is applied to update the network parameters (weights and biases) given the loss, or how far off those predictions were from our targets Y.

Source


[ad_2]

Comment List

  • John G. Fisher
    November 11, 2020

    your videos are amazing dude thank you

  • John G. Fisher
    November 11, 2020

    John, you are absolutely awesome!!! I wished you would have taught at Columbia University when I was there. I look forward to very possibly hiring you in the future for your consulting work. One question: In this dichotomous/binary response model (I suppose you would call this a logistic type regression? Am I correct?), Why do you have a seed line of code? Does this line make the initial parameters for the model (selected by the first layer in the neural network) the same every time you run the code? In other words by putting in the seed line, every time you run the code the neural network will choose the same initial parameters for the X variables? thanks again

  • John G. Fisher
    November 11, 2020

    Hello John! Can you please explain to me, how many units should we add to each layer in Keras?

  • John G. Fisher
    November 11, 2020

    Bro, you're best, really you saved my time and saved from going crazy. Every single video about neural networks, which includes keras in tensorflow, uses mnist dataset and i tried every way to fit my own data(which aren't images but only numbers) but i didn't manage. i really thank you. if you weren't, probably i would have given up. and also i'm sorry for my bad english

  • John G. Fisher
    November 11, 2020

    hello, actually i didn't understand this part X = dataset[:,0:8]

    Y = dataset[:,-1] and also i am getting error in this code. Could you please help me out??
    Could you please some contact number to contact you?

  • John G. Fisher
    November 11, 2020

    Thanks man!.Straight to the point .

  • John G. Fisher
    November 11, 2020

    Can you explain whats model.add(Dropout(0.2))?
    You do not have it in your video, but I saw that on your code at GitHub (code for this video). What does that layer represent and whats the value 0.2?

  • John G. Fisher
    November 11, 2020

    your loss is going up and down all the time :S
    in a good implementation of gradient descent that shouldnt happen in a convex function, i think you should tweak the learning rate, if thats posible with keras
    good video tho

  • John G. Fisher
    November 11, 2020

    How do we find precision and recall for this model

  • John G. Fisher
    November 11, 2020

    Dear John, I have a question… How do I obtain the weights and architecture of the model?…

    First of all, Thanks

  • John G. Fisher
    November 11, 2020

    Fantastic!!!!! Thank you so much!!!!

  • John G. Fisher
    November 11, 2020

    very helpful because of the clear line by line explanation. Thank you for your great job and Happy New Year!

  • John G. Fisher
    November 11, 2020

    Great video but i cant finde dataset. Anyone help ?

  • John G. Fisher
    November 11, 2020

    Thanks for the video tutorial but the link to the dataset is not available.

  • John G. Fisher
    November 11, 2020

    Hi John, great video. But I would like to know, how to create a new field with the probability numbers??

  • John G. Fisher
    November 11, 2020

    what a fucking god where are you at bro i Need to meet you real life being doing this for a while interested in colab brother

  • John G. Fisher
    November 11, 2020

    "The dataset is no longer available due to permission restrictions." 🙁

  • John G. Fisher
    November 11, 2020

    Thank you for this video, can you please tell me how you would set the learning rate when using the library like this? is it a parameter for the compile function?

  • John G. Fisher
    November 11, 2020

    how to predict using ANN / phyton mobile network with existing data thank you

  • John G. Fisher
    November 11, 2020

    Great explanation. Thank you for this video.

  • John G. Fisher
    November 11, 2020

    i dont know if you will see this. but if you do please reply as soon as possible.
    ValueError: could not convert string to float: 'PassengerId'

    Thanks

  • John G. Fisher
    November 11, 2020

    Bro! Amazing tutorial man! I mean you were just straight up impressive!. I want to know how do we select the number of hidden layers and the number of neurons in them? Any suggestions on where to read more about that? Thanks

  • John G. Fisher
    November 11, 2020

    Good job John I think first time ever that I actually understand how neural networks work!!!!!!
    Do you have anything in the financial recasting area?
    I appreciate ur work good man!!!!! Hi

  • John G. Fisher
    November 11, 2020

    Hi! I found the video to be excellent. But I have one doubt, if I wish to find the output for any given input (with in the range of training set), how can I do so. Can you please explain.

  • John G. Fisher
    November 11, 2020

    Thank your for this video. Please let me know if I am predicting the glucose levels of a Diabetic patient based on his input data say inslulin bolus given, food consumed, amount of exercise. How the model architecture will change? What activation functions can we use to train inner layers and finally help in making better predictions.

  • John G. Fisher
    November 11, 2020

    With all due respect, but clickbait. For real, 15 lines? I can forgive usage of numpy, but what about Keras and Tensorflow. So you have task to make a shelf, and you basically say us: "So in order to make a shelve we need to get ready made set of parts for shelve, and a screwdriver/hammer, and we do it according to manual". Dude, why we should watch it? We can buy and read manual w/o extra assistance. What we are interested in is how to make it ourselves. How to program NN, forward propagation step, purpose of different activation functions, back propagation, etc. How this video is useful for anyone?

  • John G. Fisher
    November 11, 2020

    Nice introduction but, please, speak less anxiously! Following the explanation made me feel like the end of the world was closing by!!!! (exagerating a bit, but I hope you get the point!)
    😉

  • John G. Fisher
    November 11, 2020

    Great video. I was able to internalize the information very well thanks to your explanation.

  • John G. Fisher
    November 11, 2020

    Thank you! That's a pretty clear explanation of Keras introduction.
    However, "pima" not "prima" people in India.

  • John G. Fisher
    November 11, 2020

    thumbs up and subscribed!

  • John G. Fisher
    November 11, 2020

    Extremely very well explained. I have seen many number of videos and no one explained this simple. Everyone used complex statements which was unable to understand for a beginner. But you have explained very clearly in lay man's terms. I am completely satisfied and waiting for more of your videos. If possible, could you do some more videos on Reinforcement learning basic programs, how to start coding for it, I would appreciate your help a lot.

  • John G. Fisher
    November 11, 2020

    To predict heart diseases

  • John G. Fisher
    November 11, 2020

    Make video on hybrid of two techniques like CNN AND SVM, please in python with coding.

  • John G. Fisher
    November 11, 2020

    an epoch is 1 forward pass and 1 backward propagation for each record in the dataset…. So, for example, if the training data has 750 rows, passing the first row's inputs/features through the model (forward pass), calculating the error/loss and then propagating the loss backwards (back propagation) through the data, and then moving to the next row of data. Once each row of data has passed through the model object, that is one epoch of the data. Models are generally trained for hundreds of epochs…

  • John G. Fisher
    November 11, 2020

    this is a 6 layer ANN with 4 hidden layers? 8 -> 12 -> 15 -> 8 -> 10 -> 1?

  • John G. Fisher
    November 11, 2020

    I have another question. Would accuracy improve if you scaled the data before feeding it to the ANN? I guess what I'm asking is how you feel about scaling and normalization of data…. Thanks!

  • John G. Fisher
    November 11, 2020

    Nice video. A rectified linear units or ReLU transforms the input from a previous layer into a neuron by transforming negative numbers into zero and passing positive numbers unchanged. What you are describing is a step function where any number is transformed into zero or one. small mistake in an otherwise nice video.

  • John G. Fisher
    November 11, 2020

    Is it accurate to define neural networks as correlation coefficient calculators? And if not, why? What about predictive models?

  • John G. Fisher
    November 11, 2020

    thenk you,

  • John G. Fisher
    November 11, 2020

    Bro just saying, I've watched a ton of these videos and I mean a fucking lot. No one has covered everything in the tutorial line by line and actually very well explained. Subbed

  • John G. Fisher
    November 11, 2020

    Your shit is literally the best 👌👌

  • John G. Fisher
    November 11, 2020

    I found it so informative and thank you very much for the quick and comprehensive kind of video. Currently I am working my final year thesis on "Early classification and diagnosis of diabetes using CNN". and i am facing scarcity of digitized images for diabetes to train and test my model. would you mind helping me to get those kind of data please. I am using only Indian prima data sets for the time being but this is not enough.

  • John G. Fisher
    November 11, 2020

    This is a great video. Thanks for making it sooooooo simple. You are a great teacher.

  • John G. Fisher
    November 11, 2020

    frigging awesome video mate! Cheers 🙂

  • John G. Fisher
    November 11, 2020

    Thank you for your interest in the Pima Indians Diabetes dataset.
    The dataset is no longer available due to permission restrictions.

  • John G. Fisher
    November 11, 2020

    Excellent video !

  • John G. Fisher
    November 11, 2020

    When slicing array : why do you have array[:,8] and not [:8] ?
    (with a comma)
    Thank you

  • John G. Fisher
    November 11, 2020

    Amazing video! but could u please explain why input layer has 12 neurons if input size is only 8?

Write a comment