This means that we are essentially training our model over 150 forward and backward passes, with the expectation that our loss will decrease with each epoch, meaning that our model is predicting the value of y more accurately as we continue to train the model.Let’s see what this looks like when we plot our respective losses:Both the training and validation loss decrease in an exponential fashion as the number of epochs is increased, suggesting that the model gains a high degree of accuracy as our epochs (or number of forward and backward passes) is increased.PerformanceSo, we’ve seen how we can train a neural network model, and then validate our training data against our test data in order to determine the accuracy of our model.Unlike when working with classification data, an accuracy reading does not particularly help us in this instance.The predicted car sales may be within 1% of actual car sales, but unless the predicted value is exact, then it will not be regarded as accurate.Therefore, we should redefine accuracy as the degree of deviation between the predicted and actual values.Let’s take a look at how we can calculate this:> pred <- data.frame(y = predict(model, as.matrix(X_test)))> df<-data.frame(pred,X_test)> attach(df)The following objects are masked from maxmindf: age, debt, gender, income, miles, sales> deviation=((pred-sales)/sales)> mean(deviation$y)*100 0.02819805We see that the mean deviation between predicted and actual car sales stands at 2.819%.ConclusionIn this tutorial, you have learned how to:Construct neural networks with KerasScale data appropriately with MinMaxScalerCalculate training and test lossesMake predictions using the neural network modelMany thanks for your time, and please feel free to leave any questions you have in the comments below..You can also feel free to follow more of my data science content at michaeljgrogan.com.. More details
- Automated Hyperparameter Tuning, Scaling and Tracking: On-Demand Webinar and FAQs now available!
- How to Develop an Auxiliary Classifier GAN (AC-GAN) From Scratch with Keras
- Introduction to PyTorch-Transformers: An Incredible Library for State-of-the-Art NLP (with Python code)
- How Databricks IAM Credential Passthrough Solves Common Data Authorization Problems