1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Deep Learning in Python

Exercise

Scaling up to multiple data points

You've seen how different weights will have different accuracies on a single prediction. But usually, you'll want to measure model accuracy on many points. You'll now write code to compare model accuracies for two different sets of weights, which have been stored as weights_0 and weights_1.

input_data is a list of arrays. Each item in that list contains the data to make a single prediction. target_actuals is a list of numbers. Each item in that list is the actual value we are trying to predict.

In this exercise, you'll use the mean_squared_error() function from sklearn.metrics. It takes the true values and the predicted values as arguments.

You'll also use the preloaded predict_with_network() function, which takes an array of data as the first argument, and weights as the second argument.

Instructions

100 XP
  • Import mean_squared_error from sklearn.metrics.
  • Using a for loop to iterate over each row of input_data:
    • Make predictions for each row with weights_0 using the predict_with_network() function and append it to model_output_0.
    • Do the same for weights_1, appending the predictions to model_output_1.
  • Calculate the mean squared error of model_output_0 and then model_output_1 using the mean_squared_error() function. The first argument should be the actual values (target_actuals), and the second argument should be the predicted values (model_output_0 or model_output_1).