model.py
def visualize_error(y_predictions, y_actual, baseline_predictions, model_name):
    '''
    Plot each model prediction by the error as actual value minus predicted. 
    The further from the horizontal 
    blue line, the greater the error for that prediction.
    '''
    plt.figure(figsize=(16,8))

    # a straight line for an observation having no error, would lie on this line
    plt.axhline(label="The Ideal Line: No Error")

    # the actual song popularity vs how far the prediction is from the actual
    plt.scatter(y_actual, y_predictions - y_actual, 
            alpha=.3, color='red', s=30, label=f'Model: {model_name}')

    # plot labels
    plt.legend()
    plt.xlabel("Actual Song Popularity", size=13)
    plt.ylabel("Residual/Error: Predicted Popularity - Actual Popularity", size=13)
    plt.title("Do the Size of Errors Change as the Popularity Changes?", size=15)

    plt.show()

    Plot each model prediction by the error as actual value minus predicted. 
    The further from the horizontal 
    blue line, the greater the error for that prediction.
    
Plot each model prediction by the error as actual value minus predicted.
The further from the horizontal
blue line, the greater the error for that prediction.
Plot each model prediction by the error as actual value minus predicted . The further from the horizontal blue line the greater the error for that prediction .
def visualize_error(y_predictions, y_actual, baseline_predictions, model_name):
    plt.figure(figsize=(16,8))
    plt.axhline(label="The Ideal Line: No Error")
    plt.scatter(y_actual, y_predictions - y_actual, 
            alpha=.3, color='red', s=30, label=f'Model: {model_name}')
    plt.legend()
    plt.xlabel("Actual Song Popularity", size=13)
    plt.ylabel("Residual/Error: Predicted Popularity - Actual Popularity", size=13)
    plt.title("Do the Size of Errors Change as the Popularity Changes?", size=15)
    plt.show()
def visualize_error ( y_predictions , y_actual , baseline_predictions , model_name ) : plt . figure ( figsize = ( 16 , 8 ) ) plt . axhline ( label = "The Ideal Line: No Error" ) plt . scatter ( y_actual , y_predictions - y_actual , alpha = .3 , color = 'red' , s = 30 , label = f'Model: {model_name}' ) plt . legend ( ) plt . xlabel ( "Actual Song Popularity" , size = 13 ) plt . ylabel ( "Residual/Error: Predicted Popularity - Actual Popularity" , size = 13 ) plt . title ( "Do the Size of Errors Change as the Popularity Changes?" , size = 15 ) plt . show ( )
Plot each model prediction by the error as actual value minus predicted.
Plot each model prediction by the error as actual value minus predicted .
'''
    Plot each model prediction by the error as actual value minus predicted. 
    The further from the horizontal 
    blue line, the greater the error for that prediction.
    ''' # a straight line for an observation having no error, would lie on this line # the actual song popularity vs how far the prediction is from the actual # plot labels
y_predictions
y_actual
baseline_predictions
model_name