mmgp.dimensionality_reduction ============================= .. py:module:: mmgp.dimensionality_reduction Attributes ---------- .. autoapisummary:: mmgp.dimensionality_reduction.available_dimensionality_reduction_algos Classes ------- .. autoapisummary:: mmgp.dimensionality_reduction.DimensionalityReductor Functions --------- .. autoapisummary:: mmgp.dimensionality_reduction.truncated_SVD_sym_lower Module Contents --------------- .. py:data:: available_dimensionality_reduction_algos :value: ['SnapshotPOD'] List of available dimensionality reduction algorithms .. py:class:: DimensionalityReductor(algo: str, options: dict, common_morphed_mesh: Muscat.Containers.Mesh, input_or_output: str) Bases: :py:obj:`object` The DimensionalityReductor class is designed to perform dimensionality reduction on a set of data using different algorithms. Initializes an instance of the DimensionalityReductor class. :param algo: The name of the dimensionality reduction algorithm to use. :type algo: str :param options (dict[str: Union[int, str]]): A dictionary of options and settings for the algorithm with fields 'number_of_modes' and 'correlation_type'. :param common_morphed_mesh: The mesh containing the data for dimensionality reduction. :type common_morphed_mesh: Mesh :param input_or_output: Specifies whether the data should be reduced based on input or output. :type input_or_output: str :raises AssertionError: If the specified algorithm is not supported. .. rubric:: Example .. code-block:: python from mmgp.dimensionality_reduction import DimensionalityReductor options = { 'number_of_modes': 8, 'correlation_type': 'mass_matrix' } dim_reductor = Regressor('SnapshotPOD', options) .. py:attribute:: algo :type: str .. py:attribute:: options :type: dict .. py:attribute:: common_morphed_mesh :type: Muscat.Containers.Mesh .. py:attribute:: input_or_output :type: str .. py:attribute:: training_data :type: dict :value: None .. py:method:: fit_transform(snapshots: numpy.ndarray) -> numpy.ndarray Fits and transforms the dimensionality reduction model to the data. :param snapshots: The input data snapshots to be reduced. :type snapshots: np.ndarray :returns: The reduced data in the form of generalized coordinates. :rtype: np.ndarray .. py:method:: transform(snapshots: numpy.ndarray) -> numpy.ndarray Apply dimensionality reduction to a set of data 'snapshots' :param snapshots: The input data snapshots that needs to be transformed :type snapshots: np.ndarray :returns: The transformed data or dataset resulting from the dimensionality reduction operation. :rtype: np.ndarray .. py:method:: inverse_transform(reduced_dimension_representation: numpy.ndarray) -> numpy.ndarray Reverse the dimensionality reduction transformation applied to a reduced-dimensional representation of data. :param reduced_dimension_representation: The reduced-dimensional representation of the data :type reduced_dimension_representation: np.ndarray :returns: The reconstructed data resulting from the inverse transformation. :rtype: np.ndarray .. py:function:: truncated_SVD_sym_lower(matrix: scipy.sparse.csr, epsilon: float = None, nb_modes: int = None) -> Tuple[numpy.ndarray, numpy.ndarray] Computes a truncated singular value decomposition of a symetric definite matrix in scipy.sparse.csr format. Only the lower triangular part needs to be defined :param matrix: the input matrix :type matrix: scipy.sparse.csr :param epsilon: the truncation tolerence, determining the number of keps eigenvalues :type epsilon: float :param nb_modes: the number of keps eigenvalues :type nb_modes: int :returns: * *np.ndarray* -- kept eigenvalues, of size (numberOfEigenvalues) * *np.ndarray* -- kept eigenvectors, of size (numberOfEigenvalues, numberOfSnapshots)