This repository was archived by the owner on Apr 1, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -480,6 +480,39 @@ def generate_text(
480480 return session .read_gbq_query (sql )
481481
482482
483+ @log_adapter .method_logger (custom_base_name = "bigquery_ml" )
484+ def get_insights (
485+ model : Union [bigframes .ml .base .BaseEstimator , str , pd .Series ],
486+ ) -> dataframe .DataFrame :
487+ """
488+ Gets insights from a BigQuery ML model.
489+
490+ See the `BigQuery ML GET_INSIGHTS function syntax
491+ <https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-get-insights>`_
492+ for additional reference.
493+
494+ Args:
495+ model (bigframes.ml.base.BaseEstimator, str, or pd.Series):
496+ The model to get insights from.
497+
498+ Returns:
499+ bigframes.pandas.DataFrame:
500+ The insights.
501+ """
502+ import bigframes .pandas as bpd
503+
504+ model_name , session = utils .get_model_name_and_session (model )
505+
506+ sql = bigframes .core .sql .ml .get_insights (
507+ model_name = model_name ,
508+ )
509+
510+ if session is None :
511+ return bpd .read_gbq_query (sql )
512+ else :
513+ return session .read_gbq_query (sql )
514+
515+
483516@log_adapter .method_logger (custom_base_name = "bigquery_ml" )
484517def generate_embedding (
485518 model : Union [bigframes .ml .base .BaseEstimator , str , pd .Series ],
Original file line number Diff line number Diff line change @@ -268,6 +268,16 @@ def generate_text(
268268 return sql
269269
270270
271+ def get_insights (
272+ model_name : str ,
273+ ) -> str :
274+ """Encode the ML.GET_INSIGHTS statement.
275+ See https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-get-insights for reference.
276+ """
277+ sql = f"SELECT * FROM ML.GET_INSIGHTS(MODEL { sqlglot_ir .identifier (model_name )} )\n "
278+ return sql
279+
280+
271281def generate_embedding (
272282 model_name : str ,
273283 table : str ,
You can’t perform that action at this time.
0 commit comments