All skills
google avatar

/bigquery-ai-ml

@d6b9f75
by googlegoogle/skills21k stars
1,698

Leverages BigQuery's built-in machine learning and GenAI capabilities for advanced data analytics. Use when you need to write SQL queries that perform time-series forecasting, predict values, detect outliers or anomalies, find key drivers, perform semantic search or vector search, classify text, calculate similarity, summarize content, translate language, evaluate models, filter by semantic conditions, measure the causal effect of an intervention, compute correlations between columns, detect change points or structural breaks, extract trend or seasonality components, or leverage generative AI capabilities in BigQuery. Do not use for general BigQuery dataset, table, or job management requests.

Use this Skill: https://skilld.dev/gh/google/skills/bigquery-ai-ml

This session only. Nothing lands on disk.

referencesml_trend.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

BigQuery ML.Trend

ML.TREND is a time-series decomposition function that extracts the underlying long-term direction of data, isolating the persistent growth or decline from seasonal fluctuations and random noise without requiring a pre-trained model.

Syntax Reference

SELECT
  *
FROM
  ML.TREND(
    { TABLE `project.dataset.table` | (QUERY_STATEMENT) },
    data_col => 'DATA_COL',
    timestamp_col => 'TIMESTAMP_COL'
    [, id_cols => ID_COLS]
    [, horizon => HORIZON]
    [, smoothing_window_size => SMOOTHING_WINDOW_SIZE]
    [, adjust_step_changes => ADJUST_STEP_CHANGES]
  )

Input Arguments

Argument Requirement Type Description
input_data Required The source table or query containing historical time series data.
data_col Required String The name of the numeric column in input_data. Supported types: INT64, FLOAT64, NUMERIC, BIGNUMERIC.
timestamp_col Required String The name of the date/timestamp column in input_data. Supported types: DATE, DATETIME, TIMESTAMP.
id_cols Optional Array<String> The names of the grouping columns for multiple series (e.g., ['store_id']). Supported types: STRING, INT64, ARRAY<STRING>, ARRAY<INT64>.
horizon Optional Int64 Number of future time points to forecast. Default is 0 (historical trend only). Range [1, 10,000].
smoothing_window_size Optional Int64 Size of the center moving average smoothing window used to smooth out noise before trend extraction. Default is 5. Must be positive.
adjust_step_changes Optional Bool Whether to perform automatic step change detection and adjustment. When true, identifies abrupt level shifts and blends their impact into the surrounding data before extracting the trend, generating a smoother, more continuous result.

Output Schema

Column Type Description
id_cols (As Input) Original identifiers for the series.
[timestamp_col] (As Input) The column name and type match the
: : : input column specified in :
: : : TIMESTAMP_COL. :
[data_col] FLOAT64 The column name matches the input
: : : column specified in DATA_COL. For :
: : : 'history' rows, this contains the :
: : : training data (automatically :
: : : interpolated to resolve any missing :
: : : points). For 'forecast' rows, it :
: : : contains the forecast value. :
time_series_type STRING Label: 'history' or 'forecast'.
trend FLOAT64 The calculated trend component for the
: : : time point. :
status STRING Error messages or empty string on
: : : success. A minimum of 3 data points is :
: : : required. :

Examples

Analyzing Trends in Daily Visits

This example analyzes the daily visit trend from Google Analytics sample data:

WITH DailyVisits AS (
  SELECT
    PARSE_TIMESTAMP('%Y%m%d', date) AS visit_timestamp,
    SUM(totals.visits) AS total_visits
  FROM
    `bigquery-public-data.google_analytics_sample.ga_sessions_*`
  GROUP BY
    visit_timestamp
)
SELECT
  *
FROM
  ML.TREND(
    TABLE DailyVisits,
    data_col => 'total_visits',
    timestamp_col => 'visit_timestamp'
  );

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    This skill provides a comprehensive reference for BigQuery's built-in AI and machine learning functions. It includes a security consideration regarding potential indirect prompt injection when processing untrusted data with generative AI functions. These patterns are standard for the intended data analysis use cases and can be managed through proper prompt design and data validation.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at d6b9f75. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
metadata
{
  "version": "1.1.0",
  "category": "AiAndMachineLearning"
}

README badge

README badge for google/skills/bigquery-ai-ml