FPLS#

class skfda.preprocessing.dim_reduction.FPLS(n_components=None, *, regularization_X=None, regularization_Y=None, component_basis_X=None, component_basis_Y=None, tol=1e-06, max_iter=500, _deflation_mode='can', _integration_weights_X=None, _integration_weights_Y=None)[source]#

Functional Partial Least Squares Regression.

This is a generic class. When instantiated, the type of the data in each block can be specified. The possiblities are: NDArrayFloat, FDataGrid and FDataBasis.

Parameters:
  • n_components (int | None) – Number of components to extract. By default, the maximum number of components is extracted.

  • regularization_X (L2Regularization[InputTypeX] | None) – Regularization to apply to the X block.

  • regularization_Y (L2Regularization[InputTypeY] | None) – Regularization to apply to the Y block.

  • component_basis_X (Basis | None) – Basis to use for the X block. Only applicable if X is a FDataBasis. Otherwise it must be None.

  • component_basis_Y (Basis | None) – Basis to use for the Y block. Only applicable if Y is a FDataBasis. Otherwise it must be None.

  • _deflation_mode (DeflationMode) – Mode to use for deflation. Can be “can” (dimensionality reduction) or “reg” (regression).

  • tol (float) –

  • max_iter (int) –

  • _integration_weights_X (NDArrayFloat | None) –

  • _integration_weights_Y (NDArrayFloat | None) –

Attributes:
  • x_weights_ – (n_features_X, n_components) array with the X weights extracted by NIPALS.

  • y_weights_ – (n_features_Y, n_components) array with the Y weights extracted by NIPALS.

  • x_scores_ – (n_samples, n_components) array with the X scores extracted by NIPALS.

  • y_scores_ – (n_samples, n_components) array with the Y scores extracted by NIPALS.

  • x_rotations_matrix_ – (n_features_X, n_components) array with the X rotations.

  • y_rotations_matrix_ – (n_features_Y, n_components) array with the Y rotations.

  • x_loadings_matrix_ – (n_features_X, n_components) array with the X loadings.

  • y_loadings_matrix_ – (n_features_Y, n_components) array with the Y loadings.

  • x_rotations_ – Projection directions for the X block (same type as X).

  • y_rotations_ – Projection directions for the Y block (same type as Y).

  • x_loadings_ – Loadings for the X block (same type as X).

  • y_loadings_ – Loadings for the Y block (same type as Y).

Methods

fit(X, y)

Fit the model using the data for both blocks.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_transform(X[, Y])

Transform data back to its original space.

inverse_transform_x(X)

Transform X data back to its original space.

inverse_transform_y(Y)

Transform Y data back to its original space.

set_params(**params)

Set the parameters of this estimator.

transform(X[, y])

Apply the dimension reduction learned on the train data.

transform_x(X)

Apply the dimension reduction learned on the train data.

transform_y(Y)

Apply the dimension reduction learned on the train data.

fit(X, y)[source]#

Fit the model using the data for both blocks.

Parameters:
  • X (InputTypeX) – Data of the X block

  • y (InputTypeY) – Data of the Y block

Returns:

self

Return type:

FPLS[InputTypeX, InputTypeY]

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)#

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

inverse_transform(X, Y=None)[source]#

Transform data back to its original space.

Parameters:
  • X (ndarray[Any, dtype[float64]]) – Data to transform back. Must have the same number of columns as the number of components of the model.

  • Y (ndarray[Any, dtype[float64]] | None) – Data to transform back. Must have the same number of columns as the number of components of the model.

Returns:

Data reconstructed from the transformed data. - Y: Data reconstructed from the transformed data

(if Y is not None)

Return type:

  • X

inverse_transform_x(X)[source]#

Transform X data back to its original space.

Parameters:

X (ndarray[Any, dtype[float64]]) – Data to transform back. Must have the same number of columns as the number of components of the model.

Returns:

  • Data reconstructed from the transformed data.

Return type:

InputTypeX

inverse_transform_y(Y)[source]#

Transform Y data back to its original space.

Parameters:

Y (ndarray[Any, dtype[float64]]) – Data to transform back. Must have the same number of columns as the number of components of the model.

Returns:

  • Data reconstructed from the transformed data.

Return type:

InputTypeY

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

transform(X, y=None)[source]#

Apply the dimension reduction learned on the train data.

Parameters:
  • X (InputTypeX) – Data to transform. Must have the same number of features and type as the data used to train the model.

  • y (InputTypeY | None) – Data to transform. Must have the same number of features and type as the data used to train the model. If None, only X is transformed.

Returns:

Data transformed. - y_scores: Data transformed (if y is not None)

Return type:

  • x_scores

transform_x(X)[source]#

Apply the dimension reduction learned on the train data.

Parameters:

X (InputTypeX) – Data to transform. Must have the same number of features and type as the data used to train the model.

Returns:

  • Data transformed.

Return type:

ndarray[Any, dtype[float64]]

transform_y(Y)[source]#

Apply the dimension reduction learned on the train data.

Parameters:

Y (InputTypeY) – Data to transform. Must have the same number of features and type as the data used to train the model.

Returns:

  • Data transformed.

Return type:

ndarray[Any, dtype[float64]]