docstr: Keep objects according to their predicted class
  :param workspace: workspace holding the measurements for the rules
  :param src_objects: filter these objects (uses measurement indexes instead)
  :return: indexes (base 1) of the objects that pass
docstr_tok: ["Keep","objects","according","to","their","predicted","class",":","param","workspace",":","workspace","holding","the","measurements","for","the","rules",":","param","src_objects",":","filter","these","objects","(","uses","measurement","indexes","instead",")",":","return",":","indexes","(","base","1",")","of","the","objects","that","pass"]
code: def keep_by_class(self, workspace, src_objects):
      """Keep objects according to their predicted class
      :param workspace: workspace holding the measurements for the rules
      :param src_objects: filter these objects (uses measurement indexes instead)
      :return: indexes (base 1) of the objects that pass
      """
      classifier = self.get_classifier()
      if self.get_classifier_type() == "Rules":
          return self.keep_by_rules(
              workspace, src_objects, rules=classifier
          )
      target_idx = self.get_bin_labels().index(self.rules_class.value)
      target_class = classifier.classes_[target_idx]
      features = self.split_feature_names(
          self.get_classifier_features(),
          workspace.object_set.get_object_names(),
      )
      feature_vector = numpy.column_stack(
          [
              workspace.measurements[
                  object_name,
                  self.rules.Rule.return_fuzzy_measurement_name(
                      workspace.measurements.get_measurement_columns(),
                      object_name,
                      feature_name,
                      False,
                      self.allow_fuzzy,
                  ),
              ]
              for object_name, feature_name in features
          ]
      )
      if (
          hasattr(classifier, "scaler")
          and classifier.scaler is not None
      ):
          feature_vector = classifier.scaler.transform(feature_vector)
      numpy.nan_to_num(feature_vector, copy=False)
      predicted_classes = classifier.predict(feature_vector)
      hits = predicted_classes == target_class
      indexes = numpy.argwhere(hits) + 1
      return indexes.flatten()
  
imports: from cellprofiler_core.constants.measurement import M_LOCATION_CENTER_X, M_LOCATION_CENTER_Y, C_CHILDREN, C_PARENT, C_LOCATION, C_NUMBER, FTR_OBJECT_NUMBER, C_COUNT, FTR_CENTER_X, FTR_CENTER_Y, FTR_CENTER_Z
  from cellprofiler_core.module.image_segmentation import ObjectProcessing
  from cellprofiler_core.preferences import DEFAULT_INPUT_FOLDER_NAME, ABSOLUTE_FOLDER_NAME, DEFAULT_INPUT_SUBFOLDER_NAME, DEFAULT_OUTPUT_SUBFOLDER_NAME
  from cellprofiler_core.setting import Divider, HiddenCount, SettingsGroup, Measurement, Binary, ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.do_something import DoSomething, RemoveSettingButton
  from cellprofiler_core.setting.subscriber import LabelSubscriber
  from cellprofiler_core.setting.text import Directory, Filename, Float, LabelName
  from cellprofiler.modules import _help
  import logging
  import os
  import numpy
  import scipy
  import scipy.ndimage
  import scipy.sparse
  import cellprofiler.gui.help
  import cellprofiler_core.object
  from cellprofiler.utilities.rules import Rules
label_desc: Use image node_id 25 for calling the FilterObjects obj's underlying member method code with example usage: obj.keep_by_class(workspace, src_objects) and returns: indexes, self