Sklearn PCA icon

Sklearn PCA

Principal Component Analysis using scikit-learn

Fit Transform

AI-generated

Summary

Fits a PCA model on the specified feature columns and transforms the data to principal components, adding PC1, PC2, … columns to each item and returning PCA metadata in the first item.

Inputs

  • main (required) — Input items that contain numeric values for the columns listed in featureColumns.

Output shape

Each output item retains all original columns and adds new columns PC1, PC2, … up to nComponents. The first item also includes pca_model (JSON string), explained_variance_ratio, cumulative_variance_ratio, feature_columns, and n_components.

If nComponents is set to 0, all components are kept (i.e., nComponents = min(n_samples, n_features)).

Examples

Example 1: Dimensionality reduction of a dataset with columns 'age', 'salary', 'score'.

Set Feature Columns to 'age,salary,score' and Number of Components to 2.

Discussion