Results analysis

Now that we have our neural network trained, let's use it to make some predictions to understand its accuracy.

We can create a function to make a prediction using a random sample from the testing set:

def predict_random(df_prescaled, X_test, model):    sample = X_test.sample(n=1, random_state=np.random.randint(low=0,                                                               high=10000))    idx = sample.index[0]      actual_fare = df_prescaled.loc[idx,'fare_amount']    day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',                  'Saturday', 'Sunday']    day_of_week = day_names[df_prescaled.loc[idx,'day_of_week']]    hour = df_prescaled.loc[idx,'hour']    predicted_fare = model.predict(sample)[0][0]    rmse = np.sqrt(np.square(predicted_fare-actual_fare)) print("Trip Details: {}, {}:00hrs".format(day_of_week, ...

Get Neural Network Projects with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.