watex.analysis.feature_transformation#

watex.analysis.feature_transformation(X, y=None, n_components=2, positive_class=1, view=False)[source]#

Transform X into new principal components after decomposing the covariances matrices.

Parameters:
  • X (Ndarray of shape ( M x N), \(M=m-samples\) & \(N=n-features\)) – training set; Denotes data that is observed at training and prediction time, used as independent variables in learning. The notation is uppercase to denote that it is ordinarily a matrix. When a matrix, each sample may be represented by a feature vector, or a vector of precomputed (dis)similarity with each training sample. X may also not be a matrix, and may require a feature extractor or a pairwise metric to turn it into one before learning a model.

  • y (array-like of shape (M, ) :math:`M=m-samples) – train target; Denotes data that may be observed at training time as the dependent variable in learning, but which is unavailable at prediction time, and is usually the target of prediction.

  • n_components (int, default=2) – Number of components with most total variance ratio.

  • positive_class (int,) – class label as an integer indenfier within the class representation.

  • view (bool, default {'False'}) – give an overview of the total explained variance.

Returns:

X_transf – X PCA training set transformed.

Return type:

nd-array

Examples

>>> from watex.analysis import feature_transformation
>>> # Use the X, y value in the example of `extract_pca` function
>>> Xtransf = feature_transformation(X, y=y,  positive_class = 2 , view =True)
>>> Xtransf[0]
... array([-1.0168034 ,  2.56417088])