Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Evitar overfitting
Uma armadilha comum ao treinar um modelo do BigQuery ML é o overfitting (em inglês). O overfitting ocorre quando o modelo é muito parecido com os dados de treinamento, fazendo com que ele tenha um desempenho ruim em novos dados.
O BigQuery ML é compatível com dois métodos para evitar o overfitting: parada antecipada e regularização (páginas em inglês).
A parada antecipada é a opção padrão para evitar o overfitting no BigQuery ML. Quando a parada antecipada é ativada, a perda nos dados não incluídos (páginas em inglês) é monitorada durante o treinamento, que é interrompido quando a melhoria da perda na iteração mais recente fica abaixo de um limite. Como os dados não incluídos não são usados durante o treinamento, é uma boa estimativa da perda do modelo em novos dados. As opções early_stop, min_rel_progress, data_split_method e data_split_eval_fraction controlam o comportamento da parada antecipada.
Regularização
A regularização impede que os pesos de modelo (em inglês) aumentem muito, impedindo que o modelo corresponda aos dados de treinamento com muita precisão. O BigQuery ML é compatível com dois métodos para controlar o tamanho dos pesos de modelo: regularização L1 e regularização L2 (páginas em inglês).
Por padrão, os valores de l1_reg e l2_reg são zero, o que desativa a regularização. Em alguns conjuntos de dados, definir valores positivos para l1_reg e l2_reg melhora o desempenho do modelo treinado, em novos dados. Os melhores valores para os parâmetros de regularização geralmente são encontrados por meio de tentativa e erro. É comum testar valores em várias ordens de magnitude (como 0,01; 0,1; 1; 10; e 100).
Veja alguns conselhos sobre como usar a regularização:
Se você estiver testando os parâmetros de regularização, tente desativar a parada antecipada para que o efeito da regularização seja claro.
Se o número de recursos for grande em comparação com o tamanho do conjunto de treinamento, tente valores grandes para os parâmetros de regularização. O risco de overfitting é maior quando há apenas algumas observações por recurso.
Se você estiver preocupado com a possibilidade de muitos recursos serem irrelevantes para prever o rótulo, tente definir l1_reg como maior que l2_reg e vice-versa. Há provas teóricas (em inglês) de que a regularização L1 funciona melhor quando muitos recursos são irrelevantes.
Outro benefício da regularização L1 é que ela tende a definir muitos pesos de modelo como exatamente zero, o que é útil para identificar os recursos mais relevantes e treinar um modelo compacto.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eOverfitting, where a model closely matches training data but performs poorly on new data, is a common issue in BigQuery ML model training.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery ML uses early stopping by default, which halts training when the improvement in loss on holdout data falls below a certain threshold.\u003c/p\u003e\n"],["\u003cp\u003eRegularization, which prevents model weights from becoming too large, is another method for preventing overfitting in BigQuery ML, offering L1 and L2 options.\u003c/p\u003e\n"],["\u003cp\u003eWhen using regularization, disabling early stopping can help clarify the effects of regularization, and if there are more features than observations in the training set, you can try using larger regularization values.\u003c/p\u003e\n"],["\u003cp\u003eUsing L1 regularization is beneficial for potentially identifying irrelevant features and creating smaller, more effective models because it tends to push many model weights to zero.\u003c/p\u003e\n"]]],[],null,["# Prevent overfitting\n===================\n\nA common pitfall when training a BigQuery ML model is [overfitting](https://developers.google.com/machine-learning/glossary/#overfitting). Overfitting occurs when the model matches the\ntraining data too closely, causing it to perform poorly on new data.\nBigQuery ML supports two methods for preventing overfitting: [early stopping](https://developers.google.com/machine-learning/glossary/#early_stopping) and [regularization](https://developers.google.com/machine-learning/glossary/#regularization).\n\nTo learn how to modify the options described below, see\n[the `CREATE MODEL` statement](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#model_option_list).\n\nEarly stopping\n--------------\n\nEarly stopping is the default option for overfitting prevention in\nBigQuery ML. When early stopping is enabled, the\n[loss](https://developers.google.com/machine-learning/glossary/#loss) on the\n[holdout data](https://developers.google.com/machine-learning/glossary/#holdout_data) is monitored during training, and\ntraining is halted once the loss improvement in the latest iteration falls below\na threshold. Since the holdout data is not used during training, it is a good\nestimate of the model's loss on new data. The `early_stop`, `min_rel_progress`,\n`data_split_method`, and `data_split_eval_fraction` options control the behavior\nof early stopping.\n\nRegularization\n--------------\n\nRegularization keeps the [model weights](https://developers.google.com/machine-learning/glossary/#weight)\nfrom growing too large, preventing the model from matching the training data too\nclosely. BigQuery ML supports two methods for controlling the size of\nthe model weights: [L1\nregularization](https://developers.google.com/machine-learning/glossary/#L1_regularization) and [L2\nregularization](https://developers.google.com/machine-learning/glossary/#L2_regularization).\n\nBy default, the values of `l1_reg` and `l2_reg` are zero, which disables\nregularization. On some datasets, setting positive values for `l1_reg` and\n`l2_reg` will improve the trained model's performance on new data. The best\nvalues for the regularization parameters are typically found through trial-and-\nerror, and it is common to experiment with values across several orders of\nmagnitude (for example, 0.01, 0.1, 1, 10, and 100).\n\nHere is some general advice on using regularization:\n\n- If you are experimenting with the regularization parameters, try disabling\n early stopping so that the effect of regularization is clear.\n\n- If the number of features is large compared to the size of the training set,\n try large values for the regularization parameters. The risk of overfitting is\n greater when there are only a few observations per feature.\n\n- If you are concerned that many features may be irrelevant for predicting the\n label, try setting `l1_reg` to be larger than `l2_reg` and vice versa. There is\n [theoretical evidence](http://www.robotics.stanford.edu/%7Eang/papers/icml04-l1l2.ps)\n that L1 regularization works better when many features are irrelevant.\n\nAnother benefit of L1 regularization is that it tends to set many model weights to exactly zero, which is helpful for identifying the most relevant features and training a compact model.\n\nWhat's next\n-----------\n\n- For an overview of BigQuery ML, see [Introduction to BigQuery ML](/bigquery/docs/bqml-introduction).\n- To get started using BigQuery ML, see [Create machine learning models in BigQuery ML](/bigquery/docs/create-machine-learning-model).\n- To learn more about working with models, see:\n - [Get model metadata](/bigquery/docs/getting-model-metadata)\n - [List models](/bigquery/docs/listing-models)\n - [Update model metadata](/bigquery/docs/updating-model-metadata)\n - [Manage models](/bigquery/docs/managing-models)"]]