def plot_training_results(classifier,<EOL>classlabels,<EOL>outfile):
if isinstance(classifier,str) and os.path.exists(classifier):<EOL><INDENT>with open(classifier,'<STR_LIT:rb>') as infd:<EOL><INDENT>clfdict = pickle.load(infd)<EOL><DEDENT><DEDENT>elif isinstance(classifier, dict):<EOL><INDENT>clfdict = classifier<EOL><DEDENT>else:<EOL><INDENT>LOGERROR("<STR_LIT>")<EOL>return None<EOL><DEDENT>confmatrix = clfdict['<STR_LIT>']<EOL>overall_feature_importances = clfdict[<EOL>'<STR_LIT>'<EOL>].feature_importances_<EOL>feature_importances_per_tree = np.array([<EOL>tree.feature_importances_<EOL>for tree in clfdict['<STR_LIT>'].estimators_<EOL>])<EOL>stdev_feature_importances = np.std(feature_importances_per_tree,axis=<NUM_LIT:0>)<EOL>feature_names = np.array(clfdict['<STR_LIT>'])<EOL>plt.figure(figsize=(<NUM_LIT>*<NUM_LIT>,<NUM_LIT>))<EOL>plt.subplot(<NUM_LIT>)<EOL>classes = np.array(classlabels)<EOL>plt.imshow(confmatrix, interpolation='<STR_LIT>', cmap=plt.cm.Blues)<EOL>tick_marks = np.arange(len(classes))<EOL>plt.xticks(tick_marks, classes)<EOL>plt.yticks(tick_marks, classes)<EOL>plt.title('<STR_LIT>')<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>')<EOL>thresh = confmatrix.max() / <NUM_LIT><EOL>for i, j in itertools.product(range(confmatrix.shape[<NUM_LIT:0>]),<EOL>range(confmatrix.shape[<NUM_LIT:1>])):<EOL><INDENT>plt.text(j, i, confmatrix[i, j],<EOL>horizontalalignment="<STR_LIT>",<EOL>color="<STR_LIT>" if confmatrix[i, j] > thresh else "<STR_LIT>")<EOL><DEDENT>plt.subplot(<NUM_LIT>)<EOL>features = np.array(feature_names)<EOL>sorted_ind = np.argsort(overall_feature_importances)[::-<NUM_LIT:1>]<EOL>features = features[sorted_ind]<EOL>feature_names = feature_names[sorted_ind]<EOL>overall_feature_importances = overall_feature_importances[sorted_ind]<EOL>stdev_feature_importances = stdev_feature_importances[sorted_ind]<EOL>plt.bar(np.arange(<NUM_LIT:0>,features.size),<EOL>overall_feature_importances,<EOL>yerr=stdev_feature_importances,<EOL>width=<NUM_LIT>,<EOL>color='<STR_LIT>')<EOL>plt.xticks(np.arange(<NUM_LIT:0>,features.size),<EOL>features,<EOL>rotation=<NUM_LIT>)<EOL>plt.yticks([<NUM_LIT:0.0>,<NUM_LIT:0.1>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT:0.5>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT:1.0>])<EOL>plt.xlim(-<NUM_LIT>, features.size - <NUM_LIT:1.0> + <NUM_LIT>)<EOL>plt.ylim(<NUM_LIT:0.0>,<NUM_LIT>)<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.title('<STR_LIT>')<EOL>plt.subplots_adjust(wspace=<NUM_LIT:0.1>)<EOL>plt.savefig(outfile,<EOL>bbox_inches='<STR_LIT>',<EOL>dpi=<NUM_LIT:100>)<EOL>plt.close('<STR_LIT:all>')<EOL>return outfile<EOL>
This plots the training results from the classifier run on the training
    set.

    - plots the confusion matrix

    - plots the feature importances

    - FIXME: plot the learning curves too, see:
      http://scikit-learn.org/stable/modules/learning_curve.html

    Parameters
    ----------

    classifier : dict or str
        This is the output dict or pickle created by `get_rf_classifier`
        containing the trained classifier.

    classlabels : list of str
        This contains all of the class labels for the current classification
        problem.

    outfile : str
        This is the filename where the plots will be written.

    Returns
    -------

    str
        The path to the generated plot file.