def apply_rf_classifier(classifier,<EOL>varfeaturesdir,<EOL>outpickle,<EOL>maxobjects=None):
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>if '<STR_LIT>' not in clfdict:<EOL><INDENT>LOGERROR("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % varfeaturesdir)<EOL>return None<EOL><DEDENT>featurestouse = clfdict['<STR_LIT>']<EOL>pklglob = clfdict['<STR_LIT>']['<STR_LIT>']<EOL>magcol = clfdict['<STR_LIT>']<EOL>featfile = os.path.join(<EOL>os.path.dirname(outpickle),<EOL>'<STR_LIT>'<EOL>)<EOL>features = collect_nonperiodic_features(<EOL>varfeaturesdir,<EOL>magcol,<EOL>featfile,<EOL>pklglob=pklglob,<EOL>featurestouse=featurestouse,<EOL>maxobjects=maxobjects<EOL>)<EOL>bestclf = clfdict['<STR_LIT>']<EOL>predicted_labels = bestclf.predict(features['<STR_LIT>'])<EOL>predicted_label_probs = bestclf.predict_proba(<EOL>features['<STR_LIT>']<EOL>)<EOL>outdict = {<EOL>'<STR_LIT>':features,<EOL>'<STR_LIT>':featfile,<EOL>'<STR_LIT>':clfdict,<EOL>'<STR_LIT>':predicted_labels,<EOL>'<STR_LIT>':predicted_label_probs,<EOL>}<EOL>with open(outpickle,'<STR_LIT:wb>') as outfd:<EOL><INDENT>pickle.dump(outdict, outfd, pickle.HIGHEST_PROTOCOL)<EOL><DEDENT>return outdict<EOL>
This applys an RF classifier trained using `train_rf_classifier`
    to varfeatures pickles in `varfeaturesdir`.

    Parameters
    ----------

    classifier : dict or str
        This is the output dict or pickle created by `get_rf_classifier`. This
        will contain a `features_name` key that will be used to collect the same
        features used to train the classifier from the varfeatures pickles in
        varfeaturesdir.

    varfeaturesdir : str
        The directory containing the varfeatures pickles for objects that will
        be classified by the trained `classifier`.

    outpickle : str
        This is a filename for the pickle that will be written containing the
        result dict from this function.

    maxobjects : int
        This sets the number of objects to process in `varfeaturesdir`.

    Returns
    -------

    dict
        The classification results after running the trained `classifier` as
        returned as a dict. This contains predicted labels and their prediction
        probabilities.