hyrax.verbs.reduction_algorithms.pca
====================================

.. py:module:: hyrax.verbs.reduction_algorithms.pca


Attributes
----------

.. autoapisummary::

   hyrax.verbs.reduction_algorithms.pca.logger


Classes
-------

.. autoapisummary::

   hyrax.verbs.reduction_algorithms.pca.PCA


Module Contents
---------------

.. py:data:: logger

.. py:class:: PCA(config: dict, reduction_results=None)

   Bases: :py:obj:`hyrax.verbs.reduction_algorithms.algorithm_registry.ReductionAlgorithm`


   PCA reduction implementation.


   .. py:attribute:: reducer


   .. py:method:: save_model(results_dir: pathlib.Path)

      Save the fitted PCA model to a pickle file.

      :param results_dir: The directory where the model should be saved.
                          The model will be saved as 'pca.pickle' in this directory.
      :type results_dir: Path



   .. py:method:: load_model(expected_input_dim: int, model_path: Union[pathlib.Path, str] | None = None)

      Load a pre-existing PCA model from disk.

      :param expected_input_dim: The expected number of input features for the loaded model.
      :type expected_input_dim: int
      :param model_path: The path to the file to load the model from.
                         If not specified, method will look in the config for a default model path.
      :type model_path: Path or str, optional



   .. py:method:: _validate_pca_model(reducer, expected_input_dim: int) -> None

      Validate the loaded PCA model.
      Checks that the loaded object is a PCA instance and that its
      input and output dimensions match the expected values.

      :param reducer: The loaded model object to validate.
      :type reducer: object
      :param expected_input_dim: The expected number of input features for the loaded model.
      :type expected_input_dim: int

      :raises ValueError: If the loaded model is not a PCA instance or if its input/output dimensions are incompatible.



   .. py:method:: fit(data_sample: numpy.ndarray)

      Fit the PCA model to a sample of inference data. The fitted model is stored in
      the instance variable `self.reducer` and can be used for transforming data.

      :param data_sample: The data sample used to fit the model.
      :type data_sample: numpy.ndarray



   .. py:method:: transform(args: dict, num_batches: int)

      Transform the data with the fitted PCA model. Use parallel processing if specified in the config.

      :param args: A dictionary containing the data to be transformed.
      :type args: dict
      :param num_batches: The total number of batches that the data is split into for transformation.
      :type num_batches: int



