Skip to content

Commit

Permalink
Merge branch 'develop' into fpca_references_fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vnmabus authored Feb 2, 2025
2 parents 1147336 + 6183d26 commit 1226322
Show file tree
Hide file tree
Showing 29 changed files with 79 additions and 37 deletions.
2 changes: 1 addition & 1 deletion skfda/exploratory/depth/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@


class _DepthOrOutlyingness(
BaseEstimator,
InductiveTransformerMixin[Input, NDArrayFloat, object],
BaseEstimator,
):
"""Abstract class representing a depth or outlyingness function."""

Expand Down
2 changes: 1 addition & 1 deletion skfda/exploratory/outliers/_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class BoxplotOutlierDetector(
BaseEstimator,
OutlierMixin[FDataGrid],
BaseEstimator,
):
r"""
Outlier detector using the interquartile range.
Expand Down
2 changes: 1 addition & 1 deletion skfda/exploratory/outliers/_directional_outlyingness.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def directional_outlyingness_stats( # noqa: WPS218


class MSPlotOutlierDetector( # noqa: WPS230
BaseEstimator,
OutlierMixin[FDataGrid],
BaseEstimator,
):
r"""Outlier detector using directional outlyingness.
Expand Down
2 changes: 1 addition & 1 deletion skfda/exploratory/outliers/_outliergram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class OutliergramOutlierDetector(
BaseEstimator,
OutlierMixin[FDataGrid],
BaseEstimator,
):
r"""
Outlier detector using the relation between MEI and MBD.
Expand Down
2 changes: 1 addition & 1 deletion skfda/misc/operators/_srvf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class SRSF(
Operator[FDataGrid, FDataGrid],
BaseEstimator,
InductiveTransformerMixin[FDataGrid, FDataGrid, object],
BaseEstimator,
):
r"""Square-Root Slope Function (SRSF) transform.
Expand Down
18 changes: 14 additions & 4 deletions skfda/misc/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,17 @@ def mean_squared_error(
multioutput = 'raw_values', ndarray.
"""
return sklearn.metrics.mean_squared_error( # type: ignore [no-any-return]
function = (
sklearn.metrics.mean_squared_error
if squared
else sklearn.metrics.root_mean_squared_error
)

return function( # type: ignore [no-any-return]
y_true,
y_pred,
sample_weight=sample_weight,
multioutput=multioutput,
squared=squared,
)


Expand Down Expand Up @@ -919,13 +924,18 @@ def mean_squared_log_error(
multioutput = 'raw_values', ndarray.
"""
function = (
sklearn.metrics.mean_squared_log_error
if squared
else sklearn.metrics.root_mean_squared_log_error
)

return ( # type: ignore [no-any-return]
sklearn.metrics.mean_squared_log_error(
function(
y_true,
y_pred,
sample_weight=sample_weight,
multioutput=multioutput,
squared=squared,
)
)

Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/classification/_centroid_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


class NearestCentroid(
BaseEstimator,
ClassifierMixin[Input, Target],
BaseEstimator,
):
"""
Nearest centroid classifier for functional data.
Expand Down
6 changes: 3 additions & 3 deletions skfda/ml/classification/_depth_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def _classifier_fit_depth_methods(


class DDClassifier(
BaseEstimator,
ClassifierMixin[Input, Target],
BaseEstimator,
):
"""
Depth-versus-depth (DD) classifer for functional data.
Expand Down Expand Up @@ -215,8 +215,8 @@ def predict(self, X: Input) -> Target:


class DDGClassifier(
BaseEstimator,
ClassifierMixin[Input, Target],
BaseEstimator,
):
r"""
Generalized depth-versus-depth (DD) classifier for functional data.
Expand Down Expand Up @@ -451,8 +451,8 @@ def predict(self, X: Input) -> Target:


class _ArgMaxClassifier(
BaseEstimator,
ClassifierMixin[NDArrayFloat, Target],
BaseEstimator,
):
r"""Arg max classifier for multivariate data.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/classification/_logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


class LogisticRegression(
BaseEstimator,
ClassifierMixin[FDataGrid, NDArrayAny],
BaseEstimator,
):
r"""Logistic Regression classifier for functional data.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/classification/_qda.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


class QuadraticDiscriminantAnalysis(
BaseEstimator,
ClassifierMixin[FDataGrid, Target],
BaseEstimator,
):
"""
Functional quadratic discriminant analysis.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/clustering/_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@


class BaseKMeans(
BaseEstimator,
ClusterMixin[Input],
TransformerMixin[Input, NDArrayFloat, object],
BaseEstimator,
Generic[Input, MembershipType],
):
"""Base class to implement K-Means clustering algorithms.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/regression/_fpca_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


class FPCARegression(
BaseEstimator,
RegressorMixin,
BaseEstimator,
):
r"""Regression using Functional Principal Components Analysis.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/regression/_fpls_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@


class FPLSRegression(
BaseEstimator,
RegressorMixin[InputType, OutputType],
BaseEstimator,
):
r"""
Regression using Functional Partial Least Squares.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/regression/_historical_linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def _create_fem_basis(


class HistoricalLinearRegression(
BaseEstimator,
RegressorMixin[FDataGrid, FDataGrid],
BaseEstimator,
):
r"""
Historical functional linear regression.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/regression/_kernel_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


class KernelRegression(
BaseEstimator,
RegressorMixin[Input, Prediction],
BaseEstimator,
):
r"""Kernel regression with scalar response.
Expand Down
2 changes: 1 addition & 1 deletion skfda/ml/regression/_linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@


class LinearRegression(
BaseEstimator,
RegressorMixin[
Union[AcceptedDataType, Sequence[AcceptedDataType]],
NDArrayFloat,
],
BaseEstimator,
):
r"""Linear regression with multivariate and functional response.
Expand Down
2 changes: 1 addition & 1 deletion skfda/preprocessing/dim_reduction/_fpca.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@


class FPCA( # noqa: WPS230 (too many public attributes)
BaseEstimator,
InductiveTransformerMixin[FData, NDArrayFloat, object],
BaseEstimator,
):
r"""
Principal component analysis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def _rkhs_vs(


class RKHSVariableSelection(
BaseEstimator,
InductiveTransformerMixin[FDataGrid, NDArrayFloat, NDArrayInt],
BaseEstimator,
):
r"""
Reproducing kernel variable selection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def __call__(self, X: FDataGrid) -> NDArrayInt:


class MaximaHunting(
BaseEstimator,
InductiveTransformerMixin[
FDataGrid,
NDArrayFloat,
NDArrayReal,
],
BaseEstimator,
):
r"""
Maxima Hunting variable selection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ def _mrmr(


class MinimumRedundancyMaximumRelevance(
BaseEstimator,
InductiveTransformerMixin[
FDataGrid,
NDArrayFloat,
Union[NDArrayInt, NDArrayFloat],
],
BaseEstimator,
Generic[dtype_y_T],
):
r"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,12 @@ def update_mask(


class RecursiveMaximaHunting(
BaseEstimator,
InductiveTransformerMixin[
FDataGrid,
NDArrayFloat,
Union[NDArrayInt, NDArrayFloat],
],
BaseEstimator,
):
"""
Recursive Maxima Hunting variable selection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class CoefficientsTransformer(
BaseEstimator,
TransformerMixin[FDataBasis, NDArrayFloat, object],
BaseEstimator,
):
r"""
Transformer returning the coefficients of FDataBasis objects as a matrix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@


class EvaluationTransformer(
BaseEstimator,
InductiveTransformerMixin[Input, NDArrayFloat, object],
BaseEstimator,
):
r"""
Transformer returning the evaluations of FData objects as a matrix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


class LocalAveragesTransformer(
BaseEstimator,
TransformerMixin[FData, NDArrayFloat, object],
BaseEstimator,
):
r"""
Transforms functional data to its local averages.
Expand Down Expand Up @@ -102,8 +102,8 @@ def transform(self, X: FData, y: object = None) -> NDArrayFloat:


class OccupationMeasureTransformer(
BaseEstimator,
TransformerMixin[FData, NDArrayFloat, object],
BaseEstimator,
):
"""
Transformer that works as an adapter for the occupation_measure function.
Expand Down Expand Up @@ -175,8 +175,8 @@ def transform(self, X: FData, y: object = None) -> NDArrayFloat:


class NumberCrossingsTransformer(
BaseEstimator,
TransformerMixin[FDataGrid, NDArrayInt, object],
BaseEstimator,
):
"""
Transformer that works as an adapter for the number_up_crossings function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sklearn.utils.validation import check_is_fitted as sklearn_check_is_fitted

from ..._utils import _classifier_get_classes
from ..._utils._sklearn_adapter import TransformerMixin
from ..._utils._sklearn_adapter import BaseEstimator, TransformerMixin
from ...representation import FData
from ...representation.basis import FDataBasis
from ...representation.grid import FDataGrid
Expand Down Expand Up @@ -41,7 +41,10 @@ def _fit_feature_transformer( # noqa: WPS320 WPS234
return classes, class_feature_transformers


class PerClassTransformer(TransformerMixin[Input, Output, NDArrayInt]):
class PerClassTransformer(
TransformerMixin[Input, Output, NDArrayInt],
BaseEstimator,
):
r"""Per class feature transformer for functional data.
This class takes a transformer and performs the following map:
Expand Down
2 changes: 1 addition & 1 deletion skfda/preprocessing/missing/_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def _interpolate_nans(


class MissingValuesInterpolation(
BaseEstimator,
InductiveTransformerMixin[T, T, Any],
BaseEstimator,
):
"""
Class to interpolate missing values.
Expand Down
2 changes: 1 addition & 1 deletion skfda/preprocessing/registration/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@


class RegistrationTransformer(
BaseEstimator,
TransformerMixin[Input, Output, object],
BaseEstimator,
):
"""Base class for the registration methods."""

Expand Down
2 changes: 1 addition & 1 deletion skfda/preprocessing/smoothing/_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


class _LinearSmoother(
BaseEstimator,
TransformerMixin[FDataGrid, FDataGrid, object],
BaseEstimator,
):
"""Linear smoother.
Expand Down
Loading

0 comments on commit 1226322

Please sign in to comment.