class_docstr: A Pipeline expression computing a categorical output.
  
  Classifiers are most commonly useful for describing grouping keys for
  complex transformations on Factor outputs. For example, Factor.demean() and
  Factor.zscore() can be passed a Classifier in their ``groupby`` argument,
  indicating that means/standard deviations should be computed on assets for
  which the classifier produced the same label.
class_docstr_tok: ["A","Pipeline","expression","computing","a","categorical","output",".","Classifiers","are","most","commonly","useful","for","describing","grouping","keys","for","complex","transformations","on","Factor","outputs",".","For","example",",","Factor.demean","(",")","and","Factor.zscore","(",")","can","be","passed","a","Classifier","in","their","``","groupby","``","argument",",","indicating","that","means\/standard","deviations","should","be","computed","on","assets","for","which","the","classifier","produced","the","same","label","."]
docstr: Construct a factor that gives the number of occurrences of
  each distinct category in a classifier.
  
  Parameters
  ----------
  mask : zipline.pipeline.Filter, optional
      If passed, only count assets passing the filter.  Default behavior
      is to count all assets.
  
  Examples
  --------
  Let ``c`` be a Classifier which would produce the following output::
  
                   AAPL   MSFT    MCD     BK   AMZN     FB
      2015-05-05    'a'    'a'   None    'b'    'a'   None
      2015-05-06    'b'    'a'    'c'    'b'    'b'    'b'
      2015-05-07   None    'a'   'aa'   'aa'   'aa'   None
      2015-05-08    'c'    'c'    'c'    'c'    'c'    'c'
  
  Then ``c.peer_count()`` will count, for each row, the total number
  of assets in each classifier category produced by ``c``.  Missing
  data will be evaluated to NaN.
  
  ::
  
                   AAPL   MSFT    MCD     BK   AMZN     FB
      2015-05-05    3.0    3.0    NaN    1.0    3.0    NaN
      2015-05-06    4.0    1.0    1.0    4.0    4.0    4.0
      2015-05-07    NaN    1.0    3.0    3.0    3.0    NaN
      2015-05-08    6.0    6.0    6.0    6.0    6.0    6.0
  
  Returns
  -------
  factor : CustomFactor
      A CustomFactor that counts, for each asset, the total number
      of assets with the same classifier category label.
code: def peer_count(self, mask=NotSpecified):
      """
      Construct a factor that gives the number of occurrences of
      each distinct category in a classifier.
  
      Parameters
      ----------
      mask : zipline.pipeline.Filter, optional
          If passed, only count assets passing the filter.  Default behavior
          is to count all assets.
  
      Examples
      --------
      Let ``c`` be a Classifier which would produce the following output::
  
                       AAPL   MSFT    MCD     BK   AMZN     FB
          2015-05-05    'a'    'a'   None    'b'    'a'   None
          2015-05-06    'b'    'a'    'c'    'b'    'b'    'b'
          2015-05-07   None    'a'   'aa'   'aa'   'aa'   None
          2015-05-08    'c'    'c'    'c'    'c'    'c'    'c'
  
      Then ``c.peer_count()`` will count, for each row, the total number
      of assets in each classifier category produced by ``c``.  Missing
      data will be evaluated to NaN.
  
      ::
  
                       AAPL   MSFT    MCD     BK   AMZN     FB
          2015-05-05    3.0    3.0    NaN    1.0    3.0    NaN
          2015-05-06    4.0    1.0    1.0    4.0    4.0    4.0
          2015-05-07    NaN    1.0    3.0    3.0    3.0    NaN
          2015-05-08    6.0    6.0    6.0    6.0    6.0    6.0
  
      Returns
      -------
      factor : CustomFactor
          A CustomFactor that counts, for each asset, the total number
          of assets with the same classifier category label.
      """
      # Lazy import due to cyclic dependencies in factor.py, classifier.py
      from ..factors import PeerCount
  
      return PeerCount(inputs=[self], mask=mask)
  
imports: from functools import partial
  from numbers import Number
  import operator
  import re
  from numpy import where, isnan, nan, zeros
  import pandas
  from zipline.errors import UnsupportedDataType
  from zipline.lib.labelarray import LabelArray
  from zipline.lib.quantiles import quantiles
  from zipline.pipeline.api_utils import restrict_to_dtype
  from zipline.pipeline.dtypes import CLASSIFIER_DTYPES, FACTOR_DTYPES, FILTER_DTYPES
  from zipline.pipeline.sentinels import NotSpecified
  from zipline.pipeline.term import ComputableTerm
  from zipline.utils.compat import unicode
  from zipline.utils.input_validation import expect_types, expect_dtypes
  from zipline.utils.numpy_utils import categorical_dtype, int64_dtype, vectorized_is_element
  from ..filters import ArrayPredicate, NumExprFilter
  from ..mixins import CustomTermMixin, LatestMixin, PositiveWindowLengthMixin, RestrictedDTypeMixin, SingleInputMixin, StandardOutputs
label_desc: Use image node_id 14 for calling the Classifier obj's underlying member method code with example usage: obj.peer_count(mask) and returns: PeerCount