code: def advanced_scoring_classifiers(probas, actuals, name=None):
      # pandas Series don't play nice here. Make sure our actuals list is indeed a list
      actuals = list(actuals)
      predictions = list(probas)
  
      print(
          "Here is our brier-score-loss, which is the default value we optimized for while training, and is the value returned from .score() unless you requested a custom scoring metric"
      )
      print(
          "It is a measure of how close the PROBABILITY predictions are."
      )
      if name != None:
          print(name)
  
      # Sometimes we will be given "flattened" probabilities (only the probability of our positive label), while other times we might be given "nested" probabilities (probabilities of both positive and negative, in a list, for each item).
      try:
          probas = [proba[1] for proba in probas]
      except:
          pass
  
      brier_score = brier_score_loss(actuals, probas)
      print(format(brier_score, ".4f"))
  
      print(
          "\nHere is the trained estimator's overall accuracy (when it predicts a label, how frequently is that the correct label?)"
      )
      predicted_labels = []
      for pred in probas:
          if pred >= 0.5:
              predicted_labels.append(1)
          else:
              predicted_labels.append(0)
      print(
          format(
              accuracy_score(y_true=actuals, y_pred=predicted_labels)
              * 100,
              ".1f",
          )
          + "%"
      )
  
      print(
          "\nHere is a confusion matrix showing predictions vs. actuals by label:"
      )
      # it would make sense to use sklearn's confusion_matrix here but it apparently has no labels
      # took this idea instead from: http://stats.stackexchange.com/a/109015
      conf = pd.crosstab(
          pd.Series(actuals),
          pd.Series(predicted_labels),
          rownames=["v Actual v"],
          colnames=["Predicted >"],
          margins=True,
      )
      print(conf)
  
      # I like knowing the per class accuracy to see if the model is mishandling imbalanced data.
      # For example, if it is predicting 100% of observations to one class just because it is the majority
      # Wikipedia seems to call that Positive/negative predictive value
      print("\nHere is predictive value by class:")
      df = pd.concat(
          [
              pd.Series(actuals, name="actuals"),
              pd.Series(predicted_labels, name="predicted"),
          ],
          axis=1,
      )
      targets = list(df.predicted.unique())
      for i in range(0, len(targets)):
          tot_count = len(df[df.predicted == targets[i]])
          true_count = len(
              df[
                  (df.predicted == targets[i])
                  & (df.actuals == targets[i])
              ]
          )
          print(
              "Class: ", targets[i], "=", float(true_count) / tot_count
          )
  
      # qcut is super fickle. so, try to use 10 buckets first, then 5 if that fails, then nothing
      try:
          try:
              bucket_results = pd.qcut(probas, q=10, duplicates="drop")
          except:
              bucket_results = pd.qcut(probas, q=5, duplicates="drop")
  
          df_probas = pd.DataFrame(
              probas, columns=["Predicted Probability Of Bucket"]
          )
          df_probas["Actual Probability of Bucket"] = actuals
          df_probas["Bucket Edges"] = bucket_results
  
          df_buckets = df_probas.groupby(df_probas["Bucket Edges"])
          try:
              print(
                  tabulate(
                      df_buckets.mean(),
                      headers="keys",
                      floatfmt=".4f",
                      tablefmt="psql",
                      showindex="always",
                  )
              )
          except TypeError:
              print(
                  tabulate(
                      df_buckets.mean(),
                      headers="keys",
                      floatfmt=".4f",
                      tablefmt="psql",
                  )
              )
          print(
              "\nHere is the accuracy of our trained estimator at each level of predicted probabilities"
          )
          print(
              "For a verbose description of what this means, please visit the docs:"
          )
          print(
              "http://auto-ml.readthedocs.io/en/latest/analytics.html#interpreting-predicted-probability-buckets-for-classifiers"
          )
  
      except:
          pass
  
      print("\n\n")
      return brier_score
  
imports: from collections import OrderedDict
  import math
  from auto_ml import utils
  import pandas
  from sklearn.ensemble import GradientBoostingRegressor, GradientBoostingClassifier
  from sklearn.metrics import mean_squared_error, make_scorer, brier_score_loss, accuracy_score, explained_variance_score, mean_absolute_error, median_absolute_error, r2_score, log_loss, roc_auc_score
  import numpy
  from tabulate import tabulate
label_desc: Use image node_id 1 for calling a global function with example usage: advanced_scoring_classifiers(probas, actuals, name) and returns: brier_score