本頁面中的部分或全部資訊可能不適用於 Trusted Cloud by S3NS。
BigQuery ML 模型評估總覽
本文件說明 BigQuery ML 如何支援機器學習 (ML) 模型評估作業。
模型評估總覽
您可以將 ML 模型評估指標用於下列用途:
- 評估模型與資料之間的擬合品質。
- 比較不同模型。
- 在模型選取的情況下,預測每個模型在特定資料集上的準確度。
監督式學習和非監督式學習模型的評估方式不同:
- 對於監督式學習模型,模型評估已明確定義。評估集是指尚未由模型分析的資料,通常會從訓練集中排除,然後用於評估模型效能。我們建議您不要使用訓練集進行評估,因為這會導致模型在推論新資料的預測結果時,成效不佳。這種結果稱為過度擬合。
- 對於非監督式學習模型,模型評估的定義較少,且通常因模型而異。由於非監督式學習模型不會保留評估集,因此評估指標會使用整個輸入資料集來計算。
如要瞭解每個模型類型支援的 SQL 陳述式和函式,請參閱「每個模型的端對端使用者歷程」。
模型評估服務
BigQuery ML 提供下列函式,用於計算機器學習模型的評估指標:
在 CREATE MODEL
陳述式中自動評估
BigQuery ML 支援在建立模型時自動評估。視模型類型、資料分割訓練選項,以及是否使用超參數調整功能而定,評估指標會根據保留的評估資料集、保留的測試資料集或整個輸入資料集計算。
針對 k 均值、主成分分析、自編碼器和 ARIMA_PLUS 模型,BigQuery ML 會使用所有輸入資料做為訓練資料,並根據整個輸入資料集計算評估指標。
對於線性和邏輯迴歸、提升樹、隨機森林、DNN、寬廣深度和矩陣因子模型,評估指標會根據下列 CREATE MODEL
選項指定的資料集計算:
使用超參數調整功能訓練這類模型時,DATA_SPLIT_TEST_FRACTION
選項也會協助定義評估指標的計算基準資料集。詳情請參閱「資料分割」。
如需 AutoML Tables 模型的相關資訊,請參閱如何使用資料分割作業訓練及評估模型。
如要取得在建立模型時計算的評估指標,請在未指定輸入資料的模型上使用 ML.EVALUATE
等評估函式。如需範例,請參閱未指定輸入資料的 ML.EVALUATE
。
使用新資料集進行評估
建立模型後,您可以指定新的評估資料集。如要提供新資料集,請在指定輸入資料的模型上使用 ML.EVALUATE
等評估函式。如需範例,請參閱ML.EVALUATE
含有自訂門檻和輸入資料。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-17 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-17 (世界標準時間)。"],[[["\u003cp\u003eBigQuery ML supports model evaluation to assess model-data fit, compare models, and predict model performance on new datasets.\u003c/p\u003e\n"],["\u003cp\u003eSupervised learning models utilize a separate evaluation set to prevent overfitting, while unsupervised learning models use the entire input dataset for evaluation.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery ML offers a variety of \u003ccode\u003eML.EVALUATE\u003c/code\u003e functions to calculate evaluation metrics for supervised and unsupervised models such as regressions, classifications, and clustering, each providing model-specific results.\u003c/p\u003e\n"],["\u003cp\u003eModel evaluation can be done automatically during model creation using reserved evaluation or test datasets based on the model type and chosen data split options, or with new data after creation.\u003c/p\u003e\n"],["\u003cp\u003eSpecific functions such as \u003ccode\u003eML.CONFUSION_MATRIX\u003c/code\u003e and \u003ccode\u003eML.ROC_CURVE\u003c/code\u003e are available for a more granular evaluation, including confusion matrices and metrics for different threshold values, respectively.\u003c/p\u003e\n"]]],[],null,["# BigQuery ML model evaluation overview\n=====================================\n\nThis document describes how BigQuery ML supports machine learning (ML)\nmodel evaluation.\n\nOverview of model evaluation\n----------------------------\n\nYou can use ML model evaluation metrics for the following\npurposes:\n\n- To assess the quality of the fit between the model and the data.\n- To compare different models.\n- To predict how accurately you can expect each model to perform on a specific dataset, in the context of model selection.\n\nSupervised and unsupervised learning model evaluations work differently:\n\n- For supervised learning models, model evaluation is well-defined. An evaluation set, which is data that hasn't been analyzed by the model, is typically excluded from the training set and then used to evaluate model performance. We recommend that you don't use the training set for evaluation because this causes the model to perform poorly when generalizing the prediction results for new data. This outcome is known as *overfitting*.\n- For unsupervised learning models, model evaluation is less defined and typically varies from model to model. Because unsupervised learning models don't reserve an evaluation set, the evaluation metrics are calculated using the whole input dataset.\n\nFor information about the supported SQL statements and functions for each\nmodel type, see\n[End-to-end user journey for each model](/bigquery/docs/e2e-journey).\n\nModel evaluation offerings\n--------------------------\n\nBigQuery ML provides the following functions to calculate\nevaluation metrics for ML models:\n\nAutomatic evaluation in `CREATE MODEL` statements\n-------------------------------------------------\n\nBigQuery ML supports automatic evaluation during model creation.\nDepending on the model type, the data split training options, and whether you're\nusing hyperparameter tuning, the evaluation metrics are calculated upon\nthe reserved evaluation dataset, the reserved test dataset, or the entire input\ndataset.\n\n- For k-means, PCA, autoencoder, and ARIMA_PLUS models, BigQuery ML\n uses all of the input data as training data, and evaluation metrics are\n calculated against the entire input dataset.\n\n- For linear and logistic regression, boosted tree, random forest, DNN,\n Wide-and-deep, and matrix factorization models, evaluation metrics are\n calculated against the dataset that's specified by the following\n `CREATE MODEL` options:\n\n - [`DATA_SPLIT_METHOD`](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-glm#data_split_method)\n - [`DATA_SPLIT_EVAL_FRACTION`](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-glm#data_split_eval_fraction)\n - [`DATA_SPLIT_COL`](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-glm#data_split_col)\n\n When you train these types of models using hyperparameter tuning, the\n [`DATA_SPLIT_TEST_FRACTION`](/bigquery/docs/reference/standard-sql/bigqueryml-hyperparameter-tuning#data_split) option also helps\n define the dataset that the evaluation metrics are calculated against. For\n more information, see\n [Data split](/bigquery/docs/reference/standard-sql/bigqueryml-hyperparameter-tuning#data_split).\n- For AutoML Tables models, see\n [how data splits are used](/automl-tables/docs/prepare#how_data_splits_are_used)\n for training and evaluation.\n\nTo get evaluation metrics calculated during model creation, use evaluation\nfunctions such as `ML.EVALUATE` on the model with no input data specified.\nFor an example, see\n[`ML.EVALUATE` with no input data specified](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-evaluate#mlevaluate_with_no_input_data_specified).\n\nEvaluation with a new dataset\n-----------------------------\n\nAfter model creation, you can specify new datasets for evaluation. To provide\na new dataset, use evaluation functions like `ML.EVALUATE` on the model with\ninput data specified. For an example, see\n[`ML.EVALUATE` with a custom threshold and input data](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-evaluate#mlevaluate_with_a_custom_threshold_and_input_data)."]]