class_docstr: Write out FeatureSets to files on disk.
  
  This is the base class used to create featureset writers for different
  file types.
  
  Parameters
  ----------
  path : :class:`skll.types.PathOrStr`
      A path to the feature file we would like to create. The suffix
      to this filename must be ``.arff``, ``.csv``, ``.jsonlines``,
      ``.libsvm``, ``.ndj``, or ``.tsv``. If ``subsets``
      is not ``None``, when calling the ``write()`` method, path is
      assumed to be a string containing the path to the directory to
      write the feature files with an additional file extension
      specifying the file type. For example ``/foo/.csv``.
  
  feature_set : :class:`skll.data.featureset.FeatureSet`
      The ``FeatureSet`` instance to dump to the file.
  
  quiet : bool, default=True
      Do not print "Writing..." status message to stderr.
  
  subsets : Optional[Dict[str, List[str]]], default=None
      A mapping from subset names to lists of feature names
      that are included in those sets. If given, a feature
      file will be written for every subset (with the name
      containing the subset name as suffix to ``path``).
      Note, since string- valued features are automatically
      converted into boolean features with names of the form
      ``FEATURE_NAME=STRING_VALUE``, when doing the
      filtering, the portion before the ``=`` is all that's
      used for matching. Therefore, you do not need to
      enumerate all of these boolean feature names in your
      mapping.
  
  logger : Optional[logging.Logger], default=None
      A logger instance to use to log messages instead of creating
      a new one by default.
class_docstr_tok: ["Write","out","FeatureSets","to","files","on","disk",".","This","is","the","base","class","used","to","create","featureset","writers","for","different","file","types",".","Parameters","--","--","--","--","--","path",":",":","class",":","`","skll.types.PathOrStr","`","A","path","to","the","feature","file","we","would","like","to","create",".","The","suffix","to","this","filename","must","be","``",".arff","``",",","``",".csv","``",",","``",".jsonlines","``",",","``",".libsvm","``",",","``",".ndj","``",",","or","``",".tsv","``",".","If","``","subsets","``","is","not","``","None","``",",","when","calling","the","``","write","(",")","``","method",",","path","is","assumed","to","be","a","string","containing","the","path","to","the","directory","to","write","the","feature","files","with","an","additional","file","extension","specifying","the","file","type",".","For","example","``","\/foo\/.csv","``",".","feature_set",":",":","class",":","`","skll.data.featureset.FeatureSet","`","The","``","FeatureSet","``","instance","to","dump","to","the","file",".","quiet",":","bool",",","default=True","Do","not","print","``","Writing","...","''","status","message","to","stderr",".","subsets",":","Optional","[","Dict","[","str",",","List","[","str","]","]","]",",","default=None","A","mapping","from","subset","names","to","lists","of","feature","names","that","are","included","in","those","sets",".","If","given",",","a","feature","file","will","be","written","for","every","subset","(","with","the","name","containing","the","subset","name","as","suffix","to","``","path","``",")",".","Note",",","since","string-","valued","features","are","automatically","converted","into","boolean","features","with","names","of","the","form","``","FEATURE_NAME=STRING_VALUE","``",",","when","doing","the","filtering",",","the","portion","before","the","``","=","``","is","all","that's","used","for","matching",".","Therefore",",","you","do","not","need","to","enumerate","all","of","these","boolean","feature","names","in","your","mapping",".","logger",":","Optional","[","logging.Logger","]",",","default=None","A","logger","instance","to","use","to","log","messages","instead","of","creating","a","new","one","by","default","."]
docstr: Get names of columns and associated indices for (possibly filtered) features.
  
  Parameters
  ----------
  feature_set : :class:`skll.data.featureset.FeatureSet`
      The ``FeatureSet`` instance being written to a file.
  
  filter_features : Optional[Set[str]], default=None
      If only writing a subset of the features in the
      FeatureSet to ``output_file``, these are the
      features to include in this file.
  
  Returns
  -------
  column_names : List[str]
      A list of the (possibly filtered) column names.
  
  column_indexes : List[int]
      A list of the (possibly filtered) column indexes.
docstr_tok: ["Get","names","of","columns","and","associated","indices","for","(","possibly","filtered",")","features",".","Parameters","--","--","--","--","--","feature_set",":",":","class",":","`","skll.data.featureset.FeatureSet","`","The","``","FeatureSet","``","instance","being","written","to","a","file",".","filter_features",":","Optional","[","Set","[","str","]","]",",","default=None","If","only","writing","a","subset","of","the","features","in","the","FeatureSet","to","``","output_file","``",",","these","are","the","features","to","include","in","this","file",".","Returns","--","--","--","-","column_names",":","List","[","str","]","A","list","of","the","(","possibly","filtered",")","column","names",".","column_indexes",":","List","[","int","]","A","list","of","the","(","possibly","filtered",")","column","indexes","."]
code: def _get_column_names_and_indexes(
      self,
      feature_set: FeatureSet,
      filter_features: Optional[Set[str]] = None,
  ) -> Tuple[List[str], List[int]]:
      """
      Get names of columns and associated indices for (possibly filtered) features.
  
      Parameters
      ----------
      feature_set : :class:`skll.data.featureset.FeatureSet`
          The ``FeatureSet`` instance being written to a file.
  
      filter_features : Optional[Set[str]], default=None
          If only writing a subset of the features in the
          FeatureSet to ``output_file``, these are the
          features to include in this file.
  
      Returns
      -------
      column_names : List[str]
          A list of the (possibly filtered) column names.
  
      column_indexes : List[int]
          A list of the (possibly filtered) column indexes.
      """
      # if we're not doing filtering,
      # then just take all the feature names
      self.logger.debug(feature_set)
      if isinstance(feature_set.vectorizer, DictVectorizer):
          if filter_features is None:
              filter_features = feature_set.vectorizer.feature_names_
  
          # create a list of tuples with (column names, column indexes)
          # so that we can correctly extract the appropriate columns
          columns = sorted(
              [
                  (col_name, col_idx)
                  for col_name, col_idx in feature_set.vectorizer.vocabulary_.items()
                  if (
                      col_name in filter_features
                      or col_name.split("=", 1)[0] in filter_features
                  )
              ],
              key=lambda x: x[1],
          )
  
          # then, split the names and indexes into separate lists
          column_names, column_indexes = zip(*columns)
          return list(column_names), list(column_indexes)
      else:
          return [], []
  
imports: import json
  import logging
  import sys
  from csv import DictWriter
  from decimal import Decimal
  from pathlib import Path
  from typing import IO, Any, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import pandas
  from scipy.sparse import issparse
  from sklearn.feature_extraction import DictVectorizer, FeatureHasher
  from skll.data import FeatureSet
  from skll.types import FeatGenerator, FeatureDict, IdType, LabelType, PathOrStr
label_desc: Use image node_id 8 for calling the Writer obj's underlying member method code with example usage: obj._get_column_names_and_indexes(feature_set, filter_features) and returns: list,  list, list,  list