text: # --------------------------------------------------------------------------------------------
  # Copyright (c) Microsoft Corporation. All rights reserved.
  # Licensed under the MIT License.
  # --------------------------------------------------------------------------------------------
  # - Generated by tools/entrypoint_compiler.py: do not edit by hand
  """
  PcaAnomalyDetector
  """
  
  __all__ = ["PcaAnomalyDetector"]
  
  
  from sklearn.base import ClassifierMixin
  
  from ..base_predictor import BasePredictor
  from ..internal.core.decomposition.pcaanomalydetector import \
      PcaAnomalyDetector as core
  from ..internal.utils.utils import trace
  
  
  class PcaAnomalyDetector(core, BasePredictor, ClassifierMixin):
      """
  
      Train an anomaly model using approximate PCA via randomized SVD
      algorithm
  
      .. remarks::
          ``PcaAnomalyDetector`` uses an approximate SVD decomposition of the
          data covariance matrix
          to find the principal components (eigenvectors), using a randomized
          algorithm to allow for
          efficient factorization of large datasets.
  
          PCA results in a low-rank approximation of a matrix containing the
          data to be analyzed.
          Since most of the variance in the data is captured in the subspace
          spanned by the principal
          components, the distance to the subspace can be used as a measure to
          detect outlier
          instances.
  
          The `rank` argument used to specify how many of the of largest
          principal components to use
          to approximate the final data matrix. A larger score at prediction
          time indicates that the
          instance is further away from the expected distance, and is more
          likely to be an outlier.
  
          Normalization of the dimensions (columns) is required, and by default
          is turned on. Setting
          the `normalize` argument to `No` will therefore result in poor
          performance.
  
  
  
          **Reference**
  
              `Randomized Methods for Computing the Singular Value Decomposition
              (SVD) of very large matrices
              <http://web.stanford.edu/group/mmds/slides2010/Martinsson.pdf>`_
              `A randomized algorithm for principal component analysis
              <https://arxiv.org/abs/0809.2274>`_,
              `Finding Structure with Randomness: Probabilistic Algorithms for
              Constructing Approximate Matrix Decompositions
              <http://users.cms.caltech.edu/~jtropp/papers/HMT11-Finding-Structure-
              SIREV.pdf>`_
  
  
      :param feature: see `Columns </nimbusml/concepts/columns>`_.
  
      :param weight: see `Columns </nimbusml/concepts/columns>`_.
  
      :param normalize: Specifies the type of automatic normalization used:
  
          * ``"Auto"``: if normalization is needed, it is performed
            automatically. This is the default choice.
          * ``"No"``: no normalization is performed.
          * ``"Yes"``: normalization is performed.
          * ``"Warn"``: if normalization is needed, a warning
            message is displayed, but normalization is not performed.
  
          Normalization rescales disparate data ranges to a standard scale.
          Feature
          scaling insures the distances between data points are proportional
          and
          enables various optimization methods such as gradient descent to
          converge
          much faster. If normalization is performed, a ``MaxMin`` normalizer
          is
          used. It normalizes values in an interval [a, b] where ``-1 <= a <=
          0``
          and ``0 <= b <= 1`` and ``b - a = 1``. This normalizer preserves
          sparsity by mapping zero to zero.
  
      :param caching: Whether learner should cache input training data.
  
      :param rank: The number of components in the PCA.
  
      :param oversampling: Oversampling parameter for randomized PCA training.
  
      :param center: If enabled, data is centered to be zero mean.
  
      :param random_state: The seed for random number generation.
  
      :param params: Additional arguments sent to compute engine.
  
      .. seealso::
          :py:class:`PcaTransformer <nimbusml.decomposition.PcaTransformer>`
  
  
      .. index:: models, randomized, principal, component, anomaly
  
      Example:
         .. literalinclude:: /../nimbusml/examples/PcaAnomalyDetector.py
                :language: python
      """
  
      @trace
      def __init__(
              self,
              normalize='Auto',
              caching='Auto',
              rank=20,
              oversampling=20,
              center=True,
              random_state=None,
              feature=None,
              weight=None,
              **params):
  
          if 'feature_column' in params:
              raise NameError(
                  "'feature_column' must be renamed to 'feature'")
          if feature:
              params['feature_column'] = feature
          if 'weight_column' in params:
              raise NameError(
                  "'weight_column' must be renamed to 'weight'")
          if weight:
              params['weight_column'] = weight
          BasePredictor.__init__(self, type='anomaly', **params)
          core.__init__(
              self,
              normalize=normalize,
              caching=caching,
              rank=rank,
              oversampling=oversampling,
              center=center,
              random_state=random_state,
              **params)
          self.feature = feature
          self.weight = weight
  
      def get_params(self, deep=False):
          """
          Get the parameters for this operator.
          """
          return core.get_params(self)
  