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.

referencesai_forecast.md

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

BigQuery AI.Forecast

AI.FORECAST leverages the pre-trained TimesFM foundation model to generate forecasts without the need to train and manage custom models.

Syntax Reference

SELECT
  *
FROM
  AI.FORECAST(
    { TABLE `project.dataset.table` | (QUERY_STATEMENT) },
    data_col => 'DATA_COL',
    timestamp_col => 'TIMESTAMP_COL'
    [, model => 'MODEL']
    [, id_cols => ID_COLS]
    [, horizon => HORIZON]
    [, confidence_level => CONFIDENCE_LEVEL]
    [, output_historical_time_series => OUTPUT_HISTORICAL_TIME_SERIES]
    [, context_window => CONTEXT_WINDOW]
  )

Input Arguments

Argument Requirement Type Description
input_data Required The source table or subquery containing historical data.
data_col Required String The numeric column to predict.
timestamp_col Required String The column containing dates/timestamps.
id_cols Optional Array<String> Grouping columns for multiple series (e.g., ['store_id']).
horizon Optional Int64 Number of future points to predict. Defaults to 10. The valid input range is [1, 10,000].
confidence_level Optional Float64 Confidence interval (0 to 1). Defaults to 0.95.
model Optional String Model version. Defaults to TimesFM 2.0.
context_window Optional Int64 The number of historical data points the model uses to forecast. The min value is 64 and the max value is 2048 for TimesFM 2.0. If not set, the model determines this automatically.

Output Schema

The schema adjusts based on the output_historical_time_series flag.

Column Type Included if output_historical_time_series=FALSE Included if output_historical_time_series=TRUE Description
id_cols (As Input) Yes Yes Original identifiers for the series.
forecast_timestamp TIMESTAMP Yes No Timestamp for predicted points.
forecast_value FLOAT64 Yes No The 50% quantile (median) prediction.
time_series_timestamp TIMESTAMP No Yes Uniform timestamp column for both history and forecast.
time_series_data FLOAT64 No Yes Merged column: actual values for history, median for forecast.
time_series_type STRING No Yes Label: 'history' or 'forecast'.
prediction_interval_lower_bound FLOAT64 Yes Yes Lower bound (NULL for historical rows).
prediction_interval_upper_bound FLOAT64 Yes Yes Upper bound (NULL for historical rows).
confidence_level FLOAT64 Yes Yes The constant confidence level used.
ai_forecast_status STRING Yes Yes Error messages or empty string on success. A minimum of 3 data points is required.

Examples

Forecasting with History

WITH
  citibike_trips AS (
    SELECT EXTRACT(DATE FROM starttime) AS date, usertype, COUNT(*) AS num_trips
    FROM `bigquery-public-data.new_york.citibike_trips`
    GROUP BY date, usertype
  )
SELECT *
FROM
  AI.FORECAST(
    TABLE citibike_trips,
    data_col => 'num_trips',
    timestamp_col => 'date',
    id_cols => ['usertype'],
    horizon => 30,
    output_historical_time_series => true);

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