Create A Neural Network That Classifies Diabetes Risk In 15 Lines of Python
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!
About the Dataset: https://archive.ics.uci.edu/ml/datasets/pima+indians+diabetes
Keras Docs: https://keras.io/
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.