original_docstring: 
      Use model_predictions from diagostics to calculate predictions.
      Prepare a confusion matrix plot and save as a png.
      
docstring: Use model_predictions from diagostics to calculate predictions.
  Prepare a confusion matrix plot and save as a png.
docstring_tokens: Use model_predictions from diagostics to calculate predictions . Prepare a confusion matrix plot and save as a png .
code: def score_model():
      '''
      Use model_predictions from diagostics to calculate predictions.
      Prepare a confusion matrix plot and save as a png.
      '''
  
      # read in test data to get true values
      test_data = pd.read_csv(os.path.join(
          os.getcwd(),
          test_data_path,
          'testdata.csv'))
      y = test_data['exited']
  
      # calculate predictions
      predictions = model_predictions()
  
      # calculate the confusion matrix
      conf_matrix = confusion_matrix(y, predictions)
  
      # save confusion matrix
      cm_plot = plt.matshow(conf_matrix)
      cm_plot.figure.colorbar(cm_plot)
      cm_plot.axes.set_xlabel('Predicted')
      cm_plot.axes.set_ylabel('Actual')
      cm_plot.axes.set_title('Confusion Matrix')
      # add nicely formatted numbers to the plot
      # from https://stackoverflow.com/questions/20998083/show-the-values-in-the-grid-using-matplotlib
      for (i, j), z in np.ndenumerate(conf_matrix):
          cm_plot.axes.text(j, i, '{:0.1f}'.format(z), ha='center', va='center',
              bbox=dict(boxstyle='round', facecolor='white', edgecolor='0.3'))
      # save figure
      cm_plot.figure.savefig(os.path.join(os.getcwd(), model_path, 'confusionmatrix.png'))
  
      return None
code_tokens: def score_model ( ) : test_data = pd . read_csv ( os . path . join ( os . getcwd ( ) , test_data_path , 'testdata.csv' ) ) y = test_data [ 'exited' ] predictions = model_predictions ( ) conf_matrix = confusion_matrix ( y , predictions ) cm_plot = plt . matshow ( conf_matrix ) cm_plot . figure . colorbar ( cm_plot ) cm_plot . axes . set_xlabel ( 'Predicted' ) cm_plot . axes . set_ylabel ( 'Actual' ) cm_plot . axes . set_title ( 'Confusion Matrix' ) for ( i , j ) , z in np . ndenumerate ( conf_matrix ) : cm_plot . axes . text ( j , i , '{:0.1f}' . format ( z ) , ha = 'center' , va = 'center' , bbox = dict ( boxstyle = 'round' , facecolor = 'white' , edgecolor = '0.3' ) ) cm_plot . figure . savefig ( os . path . join ( os . getcwd ( ) , model_path , 'confusionmatrix.png' ) ) return None
short_docstring: Use model_predictions from diagostics to calculate predictions.
short_docstring_tokens: Use model_predictions from diagostics to calculate predictions .
comment: '''
      Use model_predictions from diagostics to calculate predictions.
      Prepare a confusion matrix plot and save as a png.
      '''$SEP$# read in test data to get true values
  $SEP$# calculate predictions
  $SEP$# calculate the confusion matrix
  $SEP$# save confusion matrix
  $SEP$# add nicely formatted numbers to the plot
  $SEP$# from https://stackoverflow.com/questions/20998083/show-the-values-in-the-grid-using-matplotlib
  $SEP$# save figure
  