Skip to content

Commit

Permalink
Automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-2608 authored and github-actions[bot] committed Feb 26, 2025
1 parent c63addb commit 0184cd0
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 136 deletions.
2 changes: 1 addition & 1 deletion aeon/regression/_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DummyRegressor(BaseRegressor):
>>> reg.predict(X_test)[:5]
array([0.5, 0.5, 0.5, 0.5, 0.5])
"""

_tags = {
"X_inner_type": ["np-list", "numpy3D"],
"capability:missing_values": True,
Expand Down
118 changes: 59 additions & 59 deletions aeon/regression/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,29 @@ def predict(self, X) -> np.ndarray:
Parameters
----------
X : ``np.ndarray`` or ``list``
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
allowed and converted into one of the above.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
that the estimator does not support.
Returns
-------
predictions : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
Indices correspond to instance indices in ``X``.
"""
self._check_is_fitted()
Expand All @@ -148,48 +148,48 @@ def fit_predict(self, X, y) -> np.ndarray:
"""
``Fits`` the regressor and ``predicts`` class labels for ``X``.
``fit_predict`` produces prediction estimates using just the train data.
By default, this is through ``10x`` cross-validation, although some estimators
may utilize specialist techniques such as out-of-bag estimates or leave-one-out
``fit_predict`` produces prediction estimates using just the train data.
By default, this is through ``10x`` cross-validation, although some estimators
may utilize specialist techniques such as out-of-bag estimates or leave-one-out
cross-validation.
Regressors that override ``_fit_predict`` will have the
Regressors that override ``_fit_predict`` will have the
``capability:train_estimate`` tag set to ``True``.
Generally, this will not be the same as fitting on the whole train data
and then making train predictions. To do this, you should call
Generally, this will not be the same as fitting on the whole train data
and then making train predictions. To do this, you should call
``fit(X, y).predict(X)``.
Parameters
----------
X : ``np.ndarray`` or ``list``
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
allowed and converted into one of the above.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
that the estimator does not support.
y : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
(ground truth) for fitting. Indices correspond to instance indices in ``X``.
Returns
-------
predictions : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
Indices correspond to instance indices in ``X``.
"""

Expand All @@ -208,35 +208,35 @@ def score(self, X, y, metric="r2", metric_params=None) -> float:
Parameters
----------
X : ``np.ndarray`` or ``list``
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
Input data, any number of channels, equal length series of shape
``(n_cases, n_channels, n_timepoints)``
or 2D ``np.array`` (univariate, equal length series) of shape
``(n_cases, n_timepoints)``
or list of ``numpy`` arrays (any number of channels, unequal length series)
of shape ``[n_cases]``, 2D ``np.array`` ``(n_channels, n_timepoints_i)``,
where ``n_timepoints_i`` is length of series ``i``. Other types are
allowed and converted into one of the above.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
Different estimators have different capabilities to handle different
types of input. If ``self.get_tag("capability:multivariate")`` is ``False``,
they cannot handle multivariate series, so either ``n_channels == 1`` is
``True`` or ``X`` is 2D of shape ``(n_cases, n_timepoints)``.
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
If ``self.get_tag("capability:unequal_length")`` is ``False``,
they cannot handle unequal length input. In both situations,
a ``ValueError`` is raised if ``X`` has a characteristic
that the estimator does not have the capability for.
y : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
(ground truth) for fitting. Indices correspond to instance indices in ``X``.
metric : ``Union[str, callable]``, default=``"r2"``
Defines the scoring metric to test the fit of the model.
Defines the scoring metric to test the fit of the model.
For supported string arguments, check ``sklearn.metrics.get_scorer_names``.
metric_params : ``dict``, default=``None``
Contains parameters to be passed to the scoring function.
Contains parameters to be passed to the scoring function.
If ``None``, no parameters are passed.
Returns
Expand Down Expand Up @@ -285,7 +285,7 @@ def _fit(self, X, y):
List of 2D ``np.ndarray`` of shape ``(n_cases)``.
y : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
for fitting. Indices correspond to instance indices in ``X``.
Returns
Expand Down Expand Up @@ -316,10 +316,10 @@ def _predict(self, X) -> np.ndarray:
- If ``self.get_tag("X_inner_type")`` equals ``"np-list"``:
List of 2D ``np.ndarray`` of shape ``(n_cases)``.
Returns
Returns
-------
predictions : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
Indices correspond to instance indices in ``X``.
"""

Expand All @@ -339,13 +339,13 @@ def _fit_predict(self, X, y) -> np.ndarray:
List of 2D ``np.ndarray`` of shape ``(n_cases)``.
y : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - regression targets
(ground truth) for fitting, with indices corresponding to instance indices in ``X``.
Returns
-------
predictions : ``np.ndarray``
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
1D ``np.array`` of ``float``, of shape ``(n_cases)`` - predicted regression labels.
Indices correspond to instance indices in ``X``.
"""

Expand Down
2 changes: 1 addition & 1 deletion aeon/regression/compose/_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RegressorEnsemble(BaseCollectionEnsemble, BaseRegressor):
If ``None``, all estimators have equal weight.
cv : ``None``, ``int``, or ``sklearn`` cross-validation object, default=``None``
Only used if ``weights`` is a ``float``. Specifies the cross-validation strategy
to estimate model performance.
to estimate model performance.
If ``None``, predictions are obtained using each estimator's ``fit_predict`` method.
If ``int`` or ``sklearn`` object, it is passed directly to ``cross_val_predict`` from ``sklearn``.
metric : ``sklearn`` performance metric function, default=``None``
Expand Down
9 changes: 4 additions & 5 deletions aeon/regression/compose/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ class RegressorPipeline(BaseCollectionPipeline, BaseRegressor):
The ``RegressorPipeline`` compositor chains transformers and a single regressor.
The pipeline is constructed with a list of ``aeon`` transformers and a regressor,
i.e., estimators following the ``BaseTransformer`` and ``BaseRegressor`` interface.
The transformer list can be either unnamed (a simple list of transformers) or named
(a list of ``(str, estimator)`` pairs).
For a list of transformers ``trafo1``, ``trafo2``, ..., ``trafoN`` and a regressor ``reg``,
the pipeline behaves as follows:
- ``fit(X, y)``: Runs ``trafo1.fit_transform(X)``, then sequentially applies
``trafo2.fit_transform()`` to the output of ``trafo1``, and so on.
Finally, ``reg.fit()`` is run with ``X`` being the output of ``trafoN.fit_transform()``,
while ``y`` remains unchanged.
- ``predict(X)``: Sequentially applies ``trafo1.transform()``, then ``trafo2.transform()``, etc.
The final transformed ``X`` is passed to ``reg.predict()``, and the output is returned.
Expand Down Expand Up @@ -67,8 +67,7 @@ class RegressorPipeline(BaseCollectionPipeline, BaseRegressor):
RegressorPipeline(regressor=DummyRegressor(),
transformers=[AutocorrelationFunctionTransformer(n_lags=10)])
>>> y_pred = pipeline.predict(X_test)
"""

"""

_tags = {
"X_inner_type": ["numpy3D", "np-list"],
Expand Down
14 changes: 7 additions & 7 deletions aeon/regression/deep_learning/_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ class TimeCNNRegressor(BaseDeepRegressor):
optimizer : ``keras.optimizer``, default = ``tf.keras.optimizers.Adam()``
The Keras optimizer used for training.
metrics : ``str`` or ``list`` of ``str``, default = ``"mean_squared_error"``
The evaluation metrics to use during training. If a single string metric is provided,
The evaluation metrics to use during training. If a single string metric is provided,
it will be used as the only metric. If a list of metrics is provided, all will be used for evaluation.
callbacks : ``keras.callbacks.Callback`` or ``list`` of ``keras.callbacks.Callback``, default = ``None``
The default list of callbacks includes ``ModelCheckpoint``.
file_path : ``str``
File path for saving the best model (if checkpointing is used as a callback).
save_best_model : ``bool``, default = ``False``
Whether or not to save the best model. If the ``ModelCheckpoint`` callback is used
by default, setting this to ``True`` prevents the automatic deletion of the best
Whether or not to save the best model. If the ``ModelCheckpoint`` callback is used
by default, setting this to ``True`` prevents the automatic deletion of the best
saved model, allowing the user to choose the file name.
save_last_model : ``bool``, default = ``False``
Whether or not to save the last trained model using the base class method
Whether or not to save the last trained model using the base class method
``save_last_model_to_file``.
save_init_model : ``bool``, default = ``False``
Whether to save the initial model.
Expand All @@ -91,12 +91,12 @@ class TimeCNNRegressor(BaseDeepRegressor):
Notes
-----
Adapted from the implementation by Fawaz et al.
Adapted from the implementation by Fawaz et al.
Source: `https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/cnn.py`
References
----------
.. [1] Zhao et al., "Convolutional Neural Networks for Time Series Classification,"
.. [1] Zhao et al., "Convolutional Neural Networks for Time Series Classification,"
*Journal of Systems Engineering and Electronics*, 28(1), 2017.
Examples
Expand Down Expand Up @@ -329,4 +329,4 @@ def _get_test_params(cls, parameter_set="default"):
"avg_pool_size": 4,
}

return [param]
return [param]
9 changes: 4 additions & 5 deletions aeon/regression/deep_learning/_disjoint_cnn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""""DisjointCNN regressor."""
""" ""DisjointCNN regressor."""

__maintainer__ = ["hadifawaz1999"]
__all__ = ["DisjointCNNRegressor"]
Expand Down Expand Up @@ -108,7 +108,7 @@ class DisjointCNNRegressor(BaseDeepRegressor):
The name of the file of the init model.
callbacks : keras callback or list of callbacks, default=``None``
The default list of callbacks are set to ``ModelCheckpoint`` and ``ReduceLROnPlateau``.
Notes
-----
Adapted from the implementation from:
Expand Down Expand Up @@ -371,8 +371,7 @@ def _get_test_params(cls, parameter_set="default"):
Parameters to create testing instances of the class.
Each ``dict`` contains parameters to construct an "interesting" test instance, i.e.,
``MyClass(**params)`` or ``MyClass(**params[i])`` creates a valid test instance.
"""

"""
param1 = {
"n_epochs": 3,
"batch_size": 4,
Expand All @@ -393,4 +392,4 @@ def _get_test_params(cls, parameter_set="default"):
"use_mini_batch_size": True,
}

return [param1, param2]
return [param1, param2]
1 change: 1 addition & 0 deletions aeon/regression/deep_learning/_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class EncoderRegressor(BaseDeepRegressor):
for Artificial Intelligence, 120--129 2018.
"""

def __init__(
self,
n_epochs=100,
Expand Down
Loading

0 comments on commit 0184cd0

Please sign in to comment.