Stay organized with collections
Save and categorize content based on your preferences.
The ML.PRINCIPAL_COMPONENT_INFO function
This document describes the ML.PRINCIPAL_COMPONENT_INFO function, which lets
you see the statistics of the principal components in a principal component
analysis (PCA) model, such as
eigenvalue
and explained variance ratio.
Syntax
ML.PRINCIPAL_COMPONENT_INFO(
MODEL `PROJECT_ID.DATASET.MODEL`
)
Arguments
ML.PRINCIPAL_COMPONENT_INFO takes the following arguments:
PROJECT_ID: your project ID.
DATASET: the BigQuery dataset that contains
the model.
MODEL: the name of the model.
Output
ML.PRINCIPAL_COMPONENT_INFO returns the following columns:
principal_component_id: an INT64 that contains the principal
component. The table is ordered in descending order of the eigenvalue
value.
eigenvalue: a FLOAT64 value that contains the factor by which the
eigenvector is scaled. Eigenvalue and explained variance are the same
concepts in PCA.
explained_variance_ratio: a FLOAT64 value that contains the explained
variance ratio, which is the ratio between the variance, also known as
eigenvalue, of that principal component and the total variance. The total
variance is the sum of the variances from all of the individual principal
components.
cumulative_explained_variance_ratio: a FLOAT64 value that contains
the cumulative explained variance ratio of the k-th principal component,
which is the sum of the explained variance ratios of all
the previous principal components, including the k-th principal component.
Example
The following example retrieves the eigenvalue-related information of each
principal component in the model mydataset.mymodel in your default project.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eML.PRINCIPAL_COMPONENT_INFO\u003c/code\u003e function provides statistics for principal components in a PCA model, including eigenvalue and explained variance ratio.\u003c/p\u003e\n"],["\u003cp\u003eThe function's syntax requires the project ID, dataset, and model name as inputs to retrieve the principal component information.\u003c/p\u003e\n"],["\u003cp\u003eThe output includes \u003ccode\u003eprincipal_component_id\u003c/code\u003e, \u003ccode\u003eeigenvalue\u003c/code\u003e, \u003ccode\u003eexplained_variance_ratio\u003c/code\u003e, and \u003ccode\u003ecumulative_explained_variance_ratio\u003c/code\u003e to quantify the contribution of each component.\u003c/p\u003e\n"],["\u003cp\u003eThe returned \u003ccode\u003eeigenvalue\u003c/code\u003e and \u003ccode\u003eexplained variance\u003c/code\u003e are equivalent concept, being the factor that scales the eigenvector.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecumulative_explained_variance_ratio\u003c/code\u003e is the sum of all the explained variance ratios up to a certain component.\u003c/p\u003e\n"]]],[],null,["# The ML.PRINCIPAL_COMPONENT_INFO function\n========================================\n\nThis document describes the `ML.PRINCIPAL_COMPONENT_INFO` function, which lets\nyou see the statistics of the principal components in a principal component\nanalysis (PCA) model, such as\n[eigenvalue](https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors)\nand explained variance ratio.\n\nSyntax\n------\n\n```sql\nML.PRINCIPAL_COMPONENT_INFO(\n MODEL `PROJECT_ID.DATASET.MODEL`\n)\n```\n\n### Arguments\n\n`ML.PRINCIPAL_COMPONENT_INFO` takes the following arguments:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID.\n- \u003cvar translate=\"no\"\u003eDATASET\u003c/var\u003e: the BigQuery dataset that contains the model.\n- \u003cvar translate=\"no\"\u003eMODEL\u003c/var\u003e: the name of the model.\n\nOutput\n------\n\n`ML.PRINCIPAL_COMPONENT_INFO` returns the following columns:\n\n- `principal_component_id`: an `INT64` that contains the principal component. The table is ordered in descending order of the `eigenvalue` value.\n- `eigenvalue`: a `FLOAT64` value that contains the factor by which the eigenvector is scaled. Eigenvalue and explained variance are the same concepts in PCA.\n- `explained_variance_ratio`: a `FLOAT64` value that contains the explained variance ratio, which is the ratio between the variance, also known as eigenvalue, of that principal component and the total variance. The total variance is the sum of the variances from all of the individual principal components.\n- `cumulative_explained_variance_ratio`: a `FLOAT64` value that contains the cumulative explained variance ratio of the k-th principal component, which is the sum of the explained variance ratios of all the previous principal components, including the k-th principal component.\n\nExample\n-------\n\nThe following example retrieves the eigenvalue-related information of each\nprincipal component in the model `mydataset.mymodel` in your default project. \n\n```sql\nSELECT\n *\nFROM\n ML.PRINCIPAL_COMPONENT_INFO(MODEL `mydataset.mymodel`)\n```\n\nWhat's next\n-----------\n\n- For information about model weights support in BigQuery ML, see [BigQuery ML model weights overview](/bigquery/docs/weights-overview).\n- For information about the supported SQL statements and functions for each model type, see [End-to-end user journey for each model](/bigquery/docs/e2e-journey)."]]