concept no delay in category deep learning

appears as: no delay, no delays
Deep Learning with Structured Data

This is an excerpt from Manning's book Deep Learning with Structured Data.

The top left and bottom right quadrants show the number of correct predictions that the model made on the test set (that is, a subset of the dataset that was not used in the training process), while the top right and bottom left quadrants show the number of predictions that the model got wrong. Chapter 6 includes a detailed description of the confusion matrix and how to interpret it, along with details on all the parameters that make up a training experiment. For now, simply note that the bottom row of the confusion matrix shows that about 40% of the time the model predicts no delay when there actually was a delay. As you will see in Chapter 6, this outcome is the worst one for our users, so having it occur so frequently is not good. What can you do to get a better deep learning model? What is the difference between the raw input dataset as described in section 2.8 and the cleaned-up dataset that was fed into this training run? Now that you have had a taste of training a deep learning model, we will use Chapters 3 to 7 to answer these questions, and then use Chapter 8 to show you how to make your trained deep learning model available to the outside world.

  • The model predicts no delay and no delay actually happens for the trip. With this outcome the model’s prediction matches what actually happens in real life. We call this a true negative because the model predicts the event (a delay on the westbound Queen streetcar) is not going to happen prior to the trip, and the event does not happen during the trip – there is no actual delay.
  • The model predicts no delay but a delay actually happens for the trip. With this outcome the model’s prediction does not match what happens in real life. This is called a false negative because the model predicts the event (a delay on the westbound Queen streetcar) is not going to happen prior to the trip, but the event does happen during the trip – the trip is delayed.
  • The model predicts a delay but no delay actually happens for the trip. With this outcome the model’s prediction does not match what happens in real life. This is called a false positive because the model predicts the event (a delay on the westbound Queen streetcar) is going to happen prior to the trip, but the event does not happen during the trip – there is no actual delay.
  • @app.route('/') #A
    def home():  
        title_text = "Test title"
        title = {'titlename':title_text}
        return render_template('home.html',title=title) #B
     
       
    @app.route('/show-prediction/') #C
    def about():
        score_values_dict = {}
        score_values_dict['Route'] = request.args.get('route') #D
        score_values_dict['Direction'] = request.args.get('direction')
        score_values_dict['year'] = int(request.args.get('year'))
        score_values_dict['month'] = int(request.args.get('month'))
        score_values_dict['daym'] = int(request.args.get('daym'))
        score_values_dict['day'] = int(request.args.get('day'))
        score_values_dict['hour'] = int(request.args.get('hour'))
        loaded_model = load_model(model_path) #E
        loaded_model._make_predict_function()
        pipeline1 = load(open(pipeline1_path, 'rb')) #F
        pipeline2 = load(open(pipeline2_path, 'rb'))
        score_df = pd.DataFrame(columns=score_cols) #G
        for col in score_cols: #H
            score_df.at[0,col] = score_values_dict[col]
        prepped_xform1 = pipeline1.transform(score_df) #J
        prepped_xform2 = pipeline2.transform(prepped_xform1)
        pred = loaded_model.predict(prepped_xform2, batch_size=BATCH_SIZE) #K
        if pred[0][0] >= 0.5: #L
            predict_string = "yes, delay predicted"
        else:
            predict_string = "no delay predicted"
        prediction = {'prediction_key':predict_string} #M
        # render the page that will show the prediction
        return(render_template('show-prediction.html',prediction=prediction)) #N