Public dataset · Machine learning and samples
BigQuery ML Datasets in BigQuery
The ml_datasets dataset collects small, well-known machine learning tables for BigQuery ML: penguins, iris, US census income, credit card fraud, credit default, bike sharing demand and a holiday calendar for forecasting. The largest table is 67 MiB, so every query bills the 10 MB minimum or close to it.
bigquery-public-data.ml_datasets gathers benchmark tables that BigQuery ML examples and tutorials train on. Google Cloud hosts it; several table descriptions name the original source and license.
penguins (344 rows) and iris (150 rows) are the classic small classification sets. census_adult_income has one row per person with demographics and an income_bracket label, and census_adult_income_kmeans_predictions adds the output columns of a k-means model (CENTROID_ID and distances). ulb_fraud_detection is credit card transactions from two days in September 2013 by European cardholders: per its description, 492 of the 284,807 rows are fraud, and the features V1 to V28 are PCA components, with Time, Amount and the label Class left as is; it is licensed under the Open Database License. credit_card_default has payment history and a default label. bike_sharing_daily and bike_sharing_hourly are Capital Bikeshare rental counts with weather for Washington D.C. in 2011 and 2012, from the UCI ML Repository under CC BY 4.0.
holidays_and_events_for_forecasting is an external table over a CSV file in Cloud Storage. Its description says it holds holiday and event data for training ARIMA_PLUS and ARIMA_PLUS_XREG time series models and does not cover every region or every holiday.
Tables and sizes
| Table | Rows | Size | Full scan | Layout |
|---|---|---|---|---|
ulb_fraud_detectionCredit card transactions, 492 labeled as fraud. | 284,807 | 67.4 MiB | under $0.01 | None |
census_adult_income_kmeans_predictionscensus_adult_income with k-means cluster output. | 32,561 | 6.5 MiB | under $0.01 | None |
census_adult_incomeCensus records with an income bracket label. | 32,561 | 4.8 MiB | under $0.01 | None |
bike_sharing_hourlyHourly bike rentals and weather, Washington D.C., 2011 to 2012. | 17,379 | 2.3 MiB | under $0.01 | None |
credit_card_defaultCredit card clients with a default label. | 2,965 | 558 KiB | under $0.01 | None |
bike_sharing_dailyDaily bike rentals and weather, Washington D.C., 2011 to 2012. | 731 | 91.4 KiB | under $0.01 | None |
penguinsPenguin measurements by species, island and sex. | 344 | 28.3 KiB | under $0.01 | None |
irisIris flower measurements by species. | 150 | 6.2 KiB | under $0.01 | None |
holidays_and_events_for_forecastingExternal table over a CSV in Cloud Storage; BigQuery reports no size for it. | 0 | 0 B | under $0.01 | None |
Example queries
Penguin counts and average measurements by species
A typical look at class balance before training a classifier. AVG skips the rows with missing measurements.
SELECT
species,
COUNT(*) AS penguins,
ROUND(AVG(body_mass_g)) AS avg_body_mass_g,
ROUND(AVG(flipper_length_mm), 1) AS avg_flipper_mm
FROM `bigquery-public-data.ml_datasets.penguins`
GROUP BY species
ORDER BY penguins DESC;Fraud class balance and average amount
Shows how imbalanced the label is, which matters for choosing class weights and evaluation metrics.
SELECT
Class AS is_fraud,
COUNT(*) AS transactions,
ROUND(AVG(Amount), 2) AS avg_amount
FROM `bigquery-public-data.ml_datasets.ulb_fraud_detection`
GROUP BY is_fraud;Share of people earning over 50K by education
Matches the label with LIKE so the query works whatever spacing or punctuation the label values carry.
SELECT
education,
COUNT(*) AS people,
ROUND(COUNTIF(income_bracket LIKE '%>50K%') / COUNT(*), 3) AS share_over_50k
FROM `bigquery-public-data.ml_datasets.census_adult_income`
GROUP BY education
ORDER BY share_over_50k DESC;Average daily rentals and temperature by season
temp is normalized in the source data, not in degrees.
SELECT
season,
ROUND(AVG(cnt)) AS avg_daily_rentals,
ROUND(AVG(temp), 3) AS avg_normalized_temp
FROM `bigquery-public-data.ml_datasets.bike_sharing_daily`
GROUP BY season
ORDER BY season;Querying it cheaply
- Every table is small: the largest,
ulb_fraud_detection, is 67 MiB. Each query bills at least 10 MB per table referenced, so cost is never the issue here. - Training a model with
CREATE MODELis billed under BigQuery ML pricing, not like a plain query, and the model is stored in your own dataset (see BigQuery pricing). - The dataset is in the US multi-region. Create the dataset that holds your model in
UStoo, or the query fails with a location error. holidays_and_events_for_forecastingis external, so a dry run cannot estimate it and reports 0 bytes.
FAQ
How much does it cost to query ml_datasets?
Each query bills the 10 MB minimum per table, or slightly more for ulb_fraud_detection (67 MiB). That is a tiny share of the free 1 TiB a month. Training models with BigQuery ML has its own pricing.
Is the BigQuery ml_datasets dataset free?
Yes for storage: the data sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).
Can I train a BigQuery ML model directly on these tables?
Yes. Use CREATE MODEL your_dataset.model_name OPTIONS (...) AS SELECT ... FROM bigquery-public-data.ml_datasets.penguins. You need write access to your_dataset, and it must be in the US location like the source data.
Related datasets
All public datasets · BigQuery cost queries · Pricing calculator
