pyccea.projection package
Submodules
pyccea.projection.cipls module
- class pyccea.projection.cipls.CIPLS(n_components=10, copy=True)[source]
Bases:
BaseEstimatorCovariance-free Partial Least Squares (CIPLS).
Jordao, Artur, et al. “Covariance-free partial least squares: An incremental dimensionality reduction method.” Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (2021). Source: https://github.com/arturjordao/IncrementalDimensionalityReduction
- Attributes:
- n: int
Number of iterations. It starts at 0 and incrementally goes up to the number of samples (n_samples).
- n_features: int
Number of variables.
- x_weights_: np.ndarray (n_features, n_components)
Projection matrix.
- x_scores_: np.ndarray (n_samples, n_components)
The transformed training samples (latent components).
- x_loadings_: np.ndarray (n_features, n_components)
The loadings of X.
- y_loadings_: np.ndarray (n_targets, n_components)
The loadings of Y, where n_targets is the number of response variables.
- x_rotations_: np.ndarray (n_components, n_features)
Transposed and non-normalized projection matrix.
- sum_x: np.ndarray (n_features,)
The sum of each feature individually across all training samples.
- sum_y: np.ndarray (1,)
The sum of targets across all training samples.
Methods
fit(X, Y)Fit model to data
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
normalize(x)Scale input vectors individually to unit norm (vector length).
set_params(**params)Set the parameters of this estimator.
transform(X[, Y])Apply the dimension reduction learned on the training data.
pyccea.projection.kpls module
- class pyccea.projection.kpls.KernelPLS(n_components: int = 2, kernel: str = 'rbf', gamma: float | None = None, degree: int = 3, coef0: float = 1.0)[source]
Bases:
BaseEstimatorKernel Partial Least Squares (KPLS).
This class implements a kernelized version of Partial Least Squares (PLS), allowing the use of nonlinear mappings through kernel functions such as RBF, polynomial, or linear. The algorithm extracts latent components in the kernel space that maximize covariance between the predictor variables and response(s).
Methods
fit(X, Y)Fit the KernelPLS model to the training data.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict(X_new)Predict using the KernelPLS model.
set_params(**params)Set the parameters of this estimator.
set_predict_request(*[, X_new])Request metadata passed to the
predictmethod.- fit(X: ndarray, Y: ndarray)[source]
Fit the KernelPLS model to the training data.
- Parameters:
- Xndarray of shape (n_samples, n_features)
Training input data.
- Yndarray of shape (n_samples,) or (n_samples, n_targets)
Training target data.
- Returns:
- selfobject
Fitted model.
- predict(X_new: ndarray) ndarray[source]
Predict using the KernelPLS model.
- Parameters:
- X_newndarray of shape (n_samples_new, n_features)
Input samples.
- Returns:
- Y_predndarray of shape (n_samples_new, n_targets)
Predicted target values.
- set_predict_request(*, X_new: bool | None | str = '$UNCHANGED$') KernelPLS
Request metadata passed to the
predictmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
- X_newstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
X_newparameter inpredict.
- Returns:
- selfobject
The updated object.
pyccea.projection.vip module
- class pyccea.projection.vip.VIP(model)[source]
Bases:
objectVariable Importance in Projection (VIP).
Mehmood, Tahir, et al. “A review of variable selection methods in partial least squares regression.” Chemometrics and intelligent laboratory systems 118 (2012): 62-69. Source: https://github.com/scikit-learn/scikit-learn/issues/7050
- Attributes:
- n_featuresint
Number of variables.
- n_componentsint
Number of components.
- x_rotations_np.ndarray (n_features, n_components)
Projection matrix used to transform X.
- x_scores_np.ndarray (n_samples, n_components)
The transformed training samples (latent components).
- y_loadings_np.ndarray (n_targets, n_components)
The loadings of Y.
- importancesnp.ndarray (n_features,)
Importance of each feature based on its contribution to yield the latent space.
Methods
compute()Calculate feature importances.