class_docstr: A list-like object with feature names. It allows
  feature names for unknown features to be generated using
  a provided template, and to avoid making copies of large objects
  in get_feature_names.
class_docstr_tok: ["A","list-like","object","with","feature","names",".","It","allows","feature","names","for","unknown","features","to","be","generated","using","a","provided","template",",","and","to","avoid","making","copies","of","large","objects","in","get_feature_names","."]
docstr: Return feature names filtered by a regular expression 
  ``feature_re``, and indices of filtered elements.
docstr_tok: ["Return","feature","names","filtered","by","a","regular","expression","``","feature_re","``",",","and","indices","of","filtered","elements","."]
code: def filtered(self, feature_filter, x=None):
      # type: (Callable, Any) -> Tuple[FeatureNames, List[int]]
      """Return feature names filtered by a regular expression
      ``feature_re``, and indices of filtered elements.
      """
      indices = []
      filtered_feature_names = []
      indexed_names = None  # type: Optional[Iterable[Tuple[int, Any]]]
      if isinstance(self.feature_names, (np.ndarray, list)):
          indexed_names = enumerate(self.feature_names)
      elif isinstance(self.feature_names, dict):
          indexed_names = six.iteritems(self.feature_names)
      elif self.feature_names is None:
          indexed_names = []
      assert indexed_names is not None
  
      if x is not None:
          if sp.issparse(x) and len(x.shape) == 2:
              assert x.shape[0] == 1
              flt = lambda nm, i: feature_filter(nm, x[0, i])
          else:
              # FIXME: mypy warns about x[i] because it thinks x can be None
              flt = lambda nm, i: feature_filter(nm, x[i])  # type: ignore
      else:
          flt = lambda nm, i: feature_filter(nm)
  
      for idx, name in indexed_names:
          if any(flt(nm, idx) for nm in _all_feature_names(name)):
              indices.append(idx)
              filtered_feature_names.append(name)
      if self.has_bias and flt(self.bias_name, self.bias_idx):
          assert self.bias_idx is not None  # for mypy
          bias_name = self.bias_name
          indices.append(self.bias_idx)
      else:
          bias_name = None
      return (
          FeatureNames(
              filtered_feature_names,
              bias_name=bias_name,
              unkn_template=self.unkn_template,
          ),
          indices,
      )
  
file_path: eli5/eli5/_feature_names.py
imports: import re
  import six
  from typing import Any, Iterable, Iterator, Tuple, Sized, List, Optional, Dict, Union, Callable, Pattern
  import numpy
  import scipy.sparse
label_desc: Use image node_id 9 for calling the FeatureNames obj's underlying member method code with example usage: obj.filtered(feature_filter, x) and returns: FeatureNames,  indices