From 7bc2f50011b16e83e35761ac5373545754cbe291 Mon Sep 17 00:00:00 2001 From: Edwin Onuonga Date: Thu, 31 Dec 2020 13:49:23 +0400 Subject: [PATCH] [patch:docs] Fix type specifiers in documentation (#131) --- lib/sequentia/classifiers/hmm/gmmhmm.py | 32 ++++---- .../classifiers/hmm/hmm_classifier.py | 36 ++++---- .../classifiers/hmm/topologies/ergodic.py | 10 +-- .../classifiers/hmm/topologies/left_right.py | 10 +-- .../classifiers/hmm/topologies/linear.py | 10 +-- .../classifiers/hmm/topologies/topology.py | 16 ++-- .../classifiers/knn/knn_classifier.py | 54 ++++++------ lib/sequentia/internals/validator.py | 82 +++++++++---------- lib/sequentia/preprocessing/preprocess.py | 24 +++--- lib/sequentia/preprocessing/transforms.py | 40 ++++----- 10 files changed, 157 insertions(+), 157 deletions(-) diff --git a/lib/sequentia/classifiers/hmm/gmmhmm.py b/lib/sequentia/classifiers/hmm/gmmhmm.py index b9c83c1e..d83241ed 100644 --- a/lib/sequentia/classifiers/hmm/gmmhmm.py +++ b/lib/sequentia/classifiers/hmm/gmmhmm.py @@ -10,45 +10,45 @@ class GMMHMM: Parameters ---------- - label : str or numeric + label: str or numeric A label for the model, corresponding to the class being represented. - n_states : int > 0 + n_states: int > 0 The number of states for the model. - n_components : int > 0 + n_components: int > 0 The number of mixture components used in the emission distribution for each state. - covariance_type : {'spherical', 'diag', 'full', 'tied'} + covariance_type: {'spherical', 'diag', 'full', 'tied'} The covariance matrix type for emission distributions. - topology : {'ergodic', 'left-right', 'linear'} + topology: {'ergodic', 'left-right', 'linear'} The topology for the model. - random_state : numpy.random.RandomState, int, optional + random_state: numpy.random.RandomState, int, optional A random state object or seed for reproducible randomness. Attributes ---------- - label : str or numeric + label: str or numeric The label for the model. - n_states : int + n_states: int The number of states for the model. - n_components : int + n_components: int The number of mixture components used in the emission distribution for each state. - covariance_type : str + covariance_type: str The covariance matrix type for emission distributions. - n_seqs : int + n_seqs: int The number of observation sequences use to train the model. - initial : numpy.ndarray (float) + initial: numpy.ndarray (float) The initial state distribution of the model. - transitions : numpy.ndarray (float) + transitions: numpy.ndarray (float) The transition matrix of the model. """ @@ -98,7 +98,7 @@ def fit(self, X): Parameters ---------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) Collection of multivariate observation sequences, each of shape :math:`(T \\times D)` where :math:`T` may vary per observation sequence. """ @@ -133,14 +133,14 @@ def forward(self, x): Parameters ---------- - x : numpy.ndarray (float) + x: numpy.ndarray (float) An individual sequence of observations of size :math:`(T \\times D)` where :math:`T` is the number of time frames (or observations) and :math:`D` is the number of features. Returns ------- - log-likelihood : float + log-likelihood: float The log-likelihood of the model generating the observation sequence. """ try: diff --git a/lib/sequentia/classifiers/hmm/hmm_classifier.py b/lib/sequentia/classifiers/hmm/hmm_classifier.py index aed6e968..8f2ef552 100644 --- a/lib/sequentia/classifiers/hmm/hmm_classifier.py +++ b/lib/sequentia/classifiers/hmm/hmm_classifier.py @@ -9,13 +9,13 @@ class HMMClassifier: Attributes ---------- - models : list of GMMHMM + models: list of GMMHMM A collection of the :class:`~GMMHMM` objects to use for classification. - encoder : sklearn.preprocessing.LabelEncoder + encoder: sklearn.preprocessing.LabelEncoder The label encoder fitted on the set of ``classes`` provided during instantiation. - classes : numpy.ndarray (str/numeric) + classes: numpy.ndarray (str/numeric) The complete set of possible classes/labels. """ @@ -27,7 +27,7 @@ def fit(self, models): Parameters ---------- - models : array-like of GMMHMM + models: array-like of GMMHMM A collection of :class:`~GMMHMM` objects to use for classification. """ @@ -48,10 +48,10 @@ def predict(self, X, prior='frequency', return_scores=False, original_labels=Tru Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - prior : {'frequency', 'uniform'} or array-like of float + prior: {'frequency', 'uniform'} or array-like of float How the prior probability for each model is calculated to perform MAP estimation by scoring with the joint probability (or un-normalized posterior) :math:`\\mathbb{P}(O, \\lambda_c)=\\mathbb{P}(O|\\lambda_c)\\mathbb{P}(\\lambda_c)`. @@ -60,20 +60,20 @@ def predict(self, X, prior='frequency', return_scores=False, original_labels=Tru Alternatively, class prior probabilities can be specified in an iterable of floats, e.g. `[0.1, 0.3, 0.6]`. - return_scores : bool + return_scores: bool Whether to return the scores of each model on the observation sequence(s). - original_labels : bool + original_labels: bool Whether to inverse-transform the labels to their original encoding. Returns ------- - prediction(s) : str/numeric or :class:`numpy:numpy.ndarray` (str/numeric) + prediction(s): str/numeric or :class:`numpy:numpy.ndarray` (str/numeric) The predicted label(s) for the observation sequence(s). If ``original_labels`` is true, then the returned labels are inverse-transformed into their original encoding. - scores : :class:`numpy:numpy.ndarray` (float) + scores: :class:`numpy:numpy.ndarray` (float) An :math:`N\\times M` matrix of scores (log un-normalized posteriors), for each of the :math:`N` observation sequences, for each of the :math:`M` HMMs. Only returned if ``return_scores`` is true. """ @@ -122,13 +122,13 @@ def evaluate(self, X, y, prior='frequency'): Parameters ---------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) A list of multiple observation sequences. - y : array-like of str/numeric + y: array-like of str/numeric An iterable of labels for the observation sequences. - prior : {'frequency', 'uniform'} or array-like of float + prior: {'frequency', 'uniform'} or array-like of float How the prior probability for each model is calculated to perform MAP estimation by scoring with the joint probability (or un-normalized posterior) :math:`\\mathbb{P}(O, \\lambda_c)=\\mathbb{P}(O|\\lambda_c)\\mathbb{P}(\\lambda_c)`. @@ -139,10 +139,10 @@ def evaluate(self, X, y, prior='frequency'): Returns ------- - accuracy : float + accuracy: float The categorical accuracy of the classifier on the observation sequences. - confusion : :class:`numpy:numpy.ndarray` (int) + confusion: :class:`numpy:numpy.ndarray` (int) The confusion matrix representing the discrepancy between predicted and actual labels. """ X, y = self._val.observation_sequences_and_labels(X, y) @@ -155,7 +155,7 @@ def save(self, path): Parameters ---------- - path : str + path: str File path (usually with `.pkl` extension) to store the serialized :class:`HMMClassifier` object. """ try: @@ -172,12 +172,12 @@ def load(cls, path): Parameters ---------- - path : str + path: str File path of the serialized data generated by the :meth:`save` method. Returns ------- - deserialized : :class:`HMMClassifier` + deserialized: :class:`HMMClassifier` The deserialized HMM classifier object. """ with open(path, 'rb') as file: diff --git a/lib/sequentia/classifiers/hmm/topologies/ergodic.py b/lib/sequentia/classifiers/hmm/topologies/ergodic.py index f95140c0..dc67af0b 100644 --- a/lib/sequentia/classifiers/hmm/topologies/ergodic.py +++ b/lib/sequentia/classifiers/hmm/topologies/ergodic.py @@ -7,10 +7,10 @@ class _ErgodicTopology(_Topology): Parameters ---------- - n_states : int + n_states: int Number of states in the HMM. - random_state : numpy.random.RandomState + random_state: numpy.random.RandomState A random state object for reproducible randomness. """ @@ -20,7 +20,7 @@ def uniform_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The uniform transition matrix of shape `(n_states, n_states)`. """ return np.ones((self._n_states, self._n_states)) / self._n_states @@ -32,7 +32,7 @@ def random_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The random transition matrix of shape `(n_states, n_states)`. """ return self._random_state.dirichlet(np.ones(self._n_states), size=self._n_states) @@ -42,7 +42,7 @@ def validate_transitions(self, transitions: np.ndarray) -> None: Parameters ---------- - transitions : numpy.ndarray (float) + transitions: numpy.ndarray (float) The transition matrix to validate. """ super().validate_transitions(transitions) diff --git a/lib/sequentia/classifiers/hmm/topologies/left_right.py b/lib/sequentia/classifiers/hmm/topologies/left_right.py index c5206371..20e0cb59 100644 --- a/lib/sequentia/classifiers/hmm/topologies/left_right.py +++ b/lib/sequentia/classifiers/hmm/topologies/left_right.py @@ -6,10 +6,10 @@ class _LeftRightTopology(_Topology): Parameters ---------- - n_states : int + n_states: int Number of states in the HMM. - random_state : numpy.random.RandomState + random_state: numpy.random.RandomState A random state object for reproducible randomness. """ @@ -19,7 +19,7 @@ def uniform_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The uniform transition matrix of shape `(n_states, n_states)`. """ upper_ones = np.triu(np.ones((self._n_states, self._n_states))) @@ -34,7 +34,7 @@ def random_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The random transition matrix of shape `(n_states, n_states)`. """ transitions = self._random_state.dirichlet(np.ones(self._n_states), size=self._n_states) @@ -49,7 +49,7 @@ def validate_transitions(self, transitions: np.ndarray) -> None: Parameters ---------- - transitions : numpy.ndarray (float) + transitions: numpy.ndarray (float) The transition matrix to validate. """ super().validate_transitions(transitions) diff --git a/lib/sequentia/classifiers/hmm/topologies/linear.py b/lib/sequentia/classifiers/hmm/topologies/linear.py index af5b040d..780d2b17 100644 --- a/lib/sequentia/classifiers/hmm/topologies/linear.py +++ b/lib/sequentia/classifiers/hmm/topologies/linear.py @@ -6,10 +6,10 @@ class _LinearTopology(_Topology): Parameters ---------- - n_states : int + n_states: int Number of states in the HMM. - random_state : numpy.random.RandomState + random_state: numpy.random.RandomState A random state object for reproducible randomness. """ @@ -19,7 +19,7 @@ def uniform_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The uniform transition matrix of shape `(n_states, n_states)`. """ transitions = np.zeros((self._n_states, self._n_states)) @@ -35,7 +35,7 @@ def random_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The random transition matrix of shape `(n_states, n_states)`. """ transitions = np.zeros((self._n_states, self._n_states)) @@ -49,7 +49,7 @@ def validate_transitions(self, transitions: np.ndarray) -> None: Parameters ---------- - transitions : numpy.ndarray (float) + transitions: numpy.ndarray (float) The transition matrix to validate. """ super().validate_transitions(transitions) diff --git a/lib/sequentia/classifiers/hmm/topologies/topology.py b/lib/sequentia/classifiers/hmm/topologies/topology.py index 18eebcf4..7e17f1e0 100644 --- a/lib/sequentia/classifiers/hmm/topologies/topology.py +++ b/lib/sequentia/classifiers/hmm/topologies/topology.py @@ -5,10 +5,10 @@ class _Topology: Parameters ---------- - n_states : int + n_states: int Number of states in the HMM. - random_state : numpy.random.RandomState + random_state: numpy.random.RandomState A random state object for reproducible randomness. """ @@ -21,7 +21,7 @@ def uniform_initial(self) -> np.ndarray: Returns ------- - initial : :class:`numpy:numpy.ndarray` (float) + initial: :class:`numpy:numpy.ndarray` (float) The initial state distribution of shape `(n_states,)`. """ return np.ones(self._n_states) / self._n_states @@ -31,7 +31,7 @@ def random_initial(self) -> np.ndarray: Returns ------- - initial : :class:`numpy:numpy.ndarray` (float) + initial: :class:`numpy:numpy.ndarray` (float) The initial state distribution of shape `(n_states,)`. """ return self._random_state.dirichlet(np.ones(self._n_states), size=1).flatten() @@ -42,7 +42,7 @@ def uniform_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The uniform transition matrix of shape `(n_states, n_states)`. """ raise NotImplementedError @@ -54,7 +54,7 @@ def random_transitions(self) -> np.ndarray: Returns ------- - transitions : :class:`numpy:numpy.ndarray` (float) + transitions: :class:`numpy:numpy.ndarray` (float) The random transition matrix of shape `(n_states, n_states)`. """ raise NotImplementedError @@ -64,7 +64,7 @@ def validate_initial(self, initial: np.ndarray) -> None: Parameters ---------- - initial : numpy.ndarray (float) + initial: numpy.ndarray (float) The initial state distribution to validate. """ if not isinstance(initial, np.ndarray): @@ -79,7 +79,7 @@ def validate_transitions(self, transitions: np.ndarray) -> None: Parameters ---------- - transitions : numpy.ndarray (float) + transitions: numpy.ndarray (float) The transition matrix to validate. """ if not isinstance(transitions, np.ndarray): diff --git a/lib/sequentia/classifiers/knn/knn_classifier.py b/lib/sequentia/classifiers/knn/knn_classifier.py index 2eb73294..cf8c5049 100644 --- a/lib/sequentia/classifiers/knn/knn_classifier.py +++ b/lib/sequentia/classifiers/knn/knn_classifier.py @@ -17,13 +17,13 @@ class KNNClassifier: Parameters ---------- - k : int > 0 + k: int > 0 Number of neighbors. - classes : array-liike of str/numeric + classes: array-liike of str/numeric The complete set of possible classes/labels. - weighting : 'uniform' or callable + weighting: 'uniform' or callable A callable that specifies how distance weighting should be performed. The callable should accept a :class:`numpy:numpy.ndarray` of DTW distances, apply an element-wise weighting transformation, then return an equally-sized :class:`numpy:numpy.ndarray` of weighted distances. @@ -43,14 +43,14 @@ class KNNClassifier: Using the :class:`~MinMaxScale` or :class:`~Standardize` preprocessing transformations to scale your features helps to ensure that DTW distances remain small. - window : 0 ≤ float ≤ 1 + window: 0 ≤ float ≤ 1 The width of the Sakoe-Chiba band global constraint as a fraction of the length of the longest of the two sequences. A larger constraint will speed up the DTW alignment by restricting the maximum temporal deviation from the diagonal of the DTW matrix, but too much constraint may lead to poor alignment. The default value of 1 corresponds to full DTW computation with no global constraint applied. - use_c : bool + use_c: bool Whether or not to use fast pure C compiled functions (from the `dtaidistance `_ package) to perform the DTW computations. .. tip:: @@ -60,27 +60,27 @@ class KNNClassifier: pip install -vvv --upgrade --no-cache-dir --force-reinstall dtaidistance - random_state : numpy.random.RandomState, int, optional + random_state: numpy.random.RandomState, int, optional A random state object or seed for reproducible randomness. Attributes ---------- - k : int > 0 + k: int > 0 The number of neighbors. - weighting : callable + weighting: callable The distance weighting function. - window : 0 ≤ float ≤ 1 + window: 0 ≤ float ≤ 1 The width of the Sakoe-Chiba band global constraint as a fraction of the length of the longest of the two sequences. - use_c : bool + use_c: bool Whether or not to use fast pure C compiled functions to perform the DTW computations. - encoder : sklearn.preprocessing.LabelEncoder + encoder: sklearn.preprocessing.LabelEncoder The label encoder fitted on the set of ``classes`` provided during instantiation. - classes : numpy.ndarray (str/numeric) + classes: numpy.ndarray (str/numeric) The complete set of possible classes/labels. """ @@ -121,10 +121,10 @@ def fit(self, X, y): Parameters ---------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) A list of multiple observation sequences. - y : array-like of str/numeric + y: array-like of str/numeric An iterable of labels for the observation sequences. """ X, y = self._val.observation_sequences_and_labels(X, y) @@ -136,10 +136,10 @@ def predict(self, X, verbose=True, original_labels=True, n_jobs=1): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether to display a progress bar or not. .. note:: @@ -147,13 +147,13 @@ def predict(self, X, verbose=True, original_labels=True, n_jobs=1): are always displayed in the console, regardless of where you are running this function from (e.g. a Jupyter notebook). - n_jobs : int > 0 or -1 + n_jobs: int > 0 or -1 | The number of jobs to run in parallel. | Setting this to -1 will use all available CPU cores. Returns ------- - prediction(s) : str/numeric or :class:`numpy:numpy.ndarray` (str/numeric) + prediction(s): str/numeric or :class:`numpy:numpy.ndarray` (str/numeric) The predicted label(s) for the observation sequence(s). If ``original_labels`` is true, then the returned labels are @@ -182,25 +182,25 @@ def evaluate(self, X, y, verbose=True, n_jobs=1): Parameters ---------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) A list of multiple observation sequences. - y : array-like of str/numeric + y: array-like of str/numeric An iterable of labels for the observation sequences. - verbose : bool + verbose: bool Whether to display a progress bar for predictions or not. - n_jobs : int > 0 or -1 + n_jobs: int > 0 or -1 | The number of jobs to run in parallel. | Setting this to -1 will use all available CPU cores. Returns ------- - accuracy : float + accuracy: float The categorical accuracy of the classifier on the observation sequences. - confusion : :class:`numpy:numpy.ndarray` (int) + confusion: :class:`numpy:numpy.ndarray` (int) The confusion matrix representing the discrepancy between predicted and actual labels. """ X, y = self._val.observation_sequences_and_labels(X, y) @@ -218,7 +218,7 @@ def save(self, path): Parameters ---------- - path : str + path: str File path (usually with `.pkl` extension) to store the serialized :class:`KNNClassifier` object. """ try: @@ -247,12 +247,12 @@ def load(cls, path): Parameters ---------- - path : str + path: str File path of the serialized data generated by the :meth:`save` method. Returns ------- - deserialized : :class:`KNNClassifier` + deserialized: :class:`KNNClassifier` The deserialized DTW :math:`k`-NN classifier object. """ with open(path, 'rb') as file: diff --git a/lib/sequentia/internals/validator.py b/lib/sequentia/internals/validator.py index 509fad6c..b3ea9ff2 100644 --- a/lib/sequentia/internals/validator.py +++ b/lib/sequentia/internals/validator.py @@ -13,15 +13,15 @@ def observation_sequences(self, X, allow_single=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - allow_single : bool + allow_single: bool Whether to allow an individual observation sequence. Returns ------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) The original input observation sequence(s) if valid. """ X = copy(X) @@ -51,18 +51,18 @@ def observation_sequences_and_labels(self, X, y): Parameters ---------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) A list of multiple observation sequences. - y : array-like of str/numeric + y: array-like of str/numeric A list of labels for the observation sequences. Returns ------- - X : list of numpy.ndarray (float) + X: list of numpy.ndarray (float) The original input observation sequences if valid. - y : array-like of str/numeric + y: array-like of str/numeric The original input labels if valid. """ self.observation_sequences(X, allow_single=False) @@ -79,15 +79,15 @@ def integer(self, item, desc): Parameters ---------- - item : int + item: int The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : int + item: int The original input item if valid. """ if not isinstance(item, int): @@ -99,15 +99,15 @@ def string(self, item, desc): Parameters ---------- - item : str + item: str The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : str + item: str The original input item if valid. """ if not isinstance(item, str): @@ -119,15 +119,15 @@ def string_or_numeric(self, item, desc): Parameters ---------- - item : str or numeric + item: str or numeric The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : str or numeric + item: str or numeric The original input item if valid. """ if not isinstance(item, (str, numbers.Number)): @@ -139,15 +139,15 @@ def boolean(self, item, desc): Parameters ---------- - item : bool + item: bool The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : bool + item: bool The original input item if valid. """ if not isinstance(item, bool): @@ -159,18 +159,18 @@ def one_of(self, item, items, desc): Parameters ---------- - item : Any + item: Any The item to validate. - items : array-like of Any + items: array-like of Any The list of permitted values to check against. - desc : str + desc: str A description of the item being validated. Returns ------- - item : Any + item: Any The original input item if valid. """ if not item in items: @@ -182,21 +182,21 @@ def restricted_integer(self, item, condition, desc, expected): Parameters ---------- - item : int + item: int The item to validate. - condition : lambda + condition: lambda A condition to check the item against. - desc : str + desc: str A description of the item being validated. - expected : str + expected: str A description of the condition, or expected value. Returns ------- - item : int + item: int The original input item if valid. """ if isinstance(item, int): @@ -211,21 +211,21 @@ def restricted_float(self, item, condition, desc, expected): Parameters ---------- - item : float + item: float The item to validate. - condition : lambda + condition: lambda A condition to check the item against. - desc : str + desc: str A description of the item being validated. - expected : str + expected: str A description of the condition, or expected value. Returns ------- - item : float + item: float The original input item if valid. """ if isinstance(item, float): @@ -240,12 +240,12 @@ def random_state(self, state): Parameters ---------- - state : None, int, numpy.random.RandomState + state: None, int, numpy.random.RandomState A random state object or seed. Returns ------- - state : numpy.random.RandomState + state: numpy.random.RandomState A random state object. """ if state is None: @@ -262,15 +262,15 @@ def func(self, item, desc): Parameters ---------- - item : callable + item: callable The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : callable + item: callable The original input item if valid. """ if callable(item): @@ -283,15 +283,15 @@ def iterable(self, item, desc): Parameters ---------- - item : iterable + item: iterable The item to validate. - desc : str + desc: str A description of the item being validated. Returns ------- - item : iterable + item: iterable The original input item if valid. """ if isinstance(item, Iterable) and hasattr(item, '__len__'): diff --git a/lib/sequentia/preprocessing/preprocess.py b/lib/sequentia/preprocessing/preprocess.py index 8997d4a8..d8517e4a 100644 --- a/lib/sequentia/preprocessing/preprocess.py +++ b/lib/sequentia/preprocessing/preprocess.py @@ -11,7 +11,7 @@ class Preprocess: Parameters ---------- - steps : array-like of Transform + steps: array-like of Transform An ordered collection of preprocessing transformations. Examples @@ -44,15 +44,15 @@ def transform(self, X, verbose=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when applying transformations. Returns ------- - transformed : :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) + transformed: :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) The input observation sequence(s) with preprocessing transformations applied in order. """ X_t = copy(X) @@ -67,7 +67,7 @@ def __call__(self, X, verbose=False): See Also -------- - transform : Applies the transformation. + transform: Applies the transformation. """ return self.transform(X, verbose) @@ -76,10 +76,10 @@ def _fit(self, X, verbose): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when fitting transformations. """ X = self._val.observation_sequences(X, allow_single=True) @@ -95,10 +95,10 @@ def fit(self, X, verbose=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when fitting transformations. """ self._fit(X, verbose) @@ -108,15 +108,15 @@ def fit_transform(self, X, verbose=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when fitting and applying transformations. Returns ------- - transformed : :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) + transformed: :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) The input observation sequence(s) with preprocessing transformations applied in order. """ return self._fit(X, verbose) diff --git a/lib/sequentia/preprocessing/transforms.py b/lib/sequentia/preprocessing/transforms.py index 92b7f3be..e8644575 100644 --- a/lib/sequentia/preprocessing/transforms.py +++ b/lib/sequentia/preprocessing/transforms.py @@ -16,7 +16,7 @@ def _describe(self): Returns ------- - description : str + description: str The description of the transformation. """ raise NotImplementedError @@ -26,15 +26,15 @@ def transform(self, X, verbose=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when applying transformations. Returns ------- - transformed : :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) + transformed: :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) The transformed input observation sequence(s). """ raise NotImplementedError @@ -48,15 +48,15 @@ def _apply(self, transform, X, verbose): Parameters ---------- - transform : callable + transform: callable The transformation to apply. - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. Returns ------- - transformed : numpy.ndarray (float) or list of numpy.ndarray (float) + transformed: numpy.ndarray (float) or list of numpy.ndarray (float) The transformed input observation sequence(s). """ X = self._val.observation_sequences(X, allow_single=True) @@ -84,7 +84,7 @@ def fit(self, X): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. """ self._val.observation_sequences(X, allow_single=True) @@ -98,7 +98,7 @@ def _is_fitted(self): Returns ------- - fitted : bool + fitted: bool Whether or not the transformation is fitted. """ return False @@ -108,15 +108,15 @@ def fit_transform(self, X, verbose=False): Parameters ---------- - X : numpy.ndarray (float) or list of numpy.ndarray (float) + X: numpy.ndarray (float) or list of numpy.ndarray (float) An individual observation sequence or a list of multiple observation sequences. - verbose : bool + verbose: bool Whether or not to display a progress bar when fitting and applying transformations. Returns ------- - transformed : :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) + transformed: :class:`numpy:numpy.ndarray` (float) or list of :class:`numpy:numpy.ndarray` (float) The transformed input observation sequence(s). """ self.fit(X) @@ -174,10 +174,10 @@ class MinMaxScale(Transform): Parameters ---------- - scale : tuple(int/float, int/float) + scale: tuple(int/float, int/float) The range of the transformed observation sequence features. - independent : bool + independent: bool Whether to independently compute the minimum and maximum to scale each observation sequence. """ @@ -231,7 +231,7 @@ class Center(Transform): Parameters ---------- - independent : bool + independent: bool Whether to independently compute the mean to scale each observation sequence. Examples @@ -282,7 +282,7 @@ class Standardize(Transform): Parameters ---------- - independent : bool + independent: bool Whether to independently compute the mean and standard deviation to scale each observation sequence. Examples @@ -335,10 +335,10 @@ class Downsample(Transform): Parameters ---------- - factor : int > 0 + factor: int > 0 Downsample factor. - method : {'decimate', 'mean'} + method: {'decimate', 'mean'} The downsampling method. Examples @@ -385,10 +385,10 @@ class Filter(Transform): Parameters ---------- - window_size : int > 0 + window_size: int > 0 The size of the filtering window. - method : {'median', 'mean'} + method: {'median', 'mean'} The filtering method. Examples