Back to cookbook

AI Prompt to Detect Outliers and Anomalies in a Dataset

17 views Published

Make this prompt yours

Share

This AI prompt for detecting outliers and anomalies in a dataset is for analysts and data scientists who have a table of numbers — sales figures, sensor readings, transaction amounts — and need a first pass at flagging values that don't fit the pattern before deciding whether they're errors, fraud, or genuinely interesting edge cases. It's meant as a starting point for exploration, not a replacement for a proper statistical pipeline.

The prompt asks the model to look at each numeric column separately, describe what a "normal" range looks like based on the data it's given, and list specific rows or values that fall outside that range along with a plain-language reason why. It also asks the model to flag anything that looks like a likely data-entry error (a negative age, a date in the future) separately from a statistical outlier (a value that's just unusually high or low), since those need different follow-up.

Because this kind of analysis works best on a focused slice of data rather than an entire raw file, pulling just the relevant columns or rows first with Context Extractor before running this prompt keeps the model working from clean, targeted data instead of skimming a huge CSV.

Prompt template

Make this prompt yours

prompt-template
302 tokens
ROLE: You are a data analyst reviewing a dataset for outliers and anomalies before further analysis. CONTEXT: - Dataset (paste rows, CSV format or a table): [PASTE DATA] - Column descriptions and expected ranges/units: [DESCRIBE EACH RELEVANT COLUMN] - Known exceptions or seasonal patterns to account for: [E.G. "DECEMBER SALES ARE NORMALLY 3X HIGHER"] TASK: 1. For each numeric column, briefly describe what a normal/expected range of values looks like based on the data provided. 2. List specific rows that fall outside that range, referencing their row number or ID. 3. For each flagged row, classify it as either a likely data-entry error (e.g. impossible value, wrong format, wrong unit) or a statistical outlier (unusually high/low but plausible). 4. Give a one-sentence reason for each flag. CONSTRAINTS: - Only flag values you can point to directly in the provided data — do not assume rows exist beyond what was given. - Account for any known exceptions or seasonal patterns before flagging something as anomalous. - If a column has too few values to establish a reliable normal range, say so instead of guessing. OUTPUT FORMAT: Column: [name] - Expected range: [description] - Flagged rows: - Row [ID/number]: [value] — [Data-entry error / Statistical outlier] — [reason] (repeat per column)

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
138 tokens
Dataset: Row1: order_id=101, amount=42.50, region=West | Row2: order_id=102, amount=38.00, region=East | Row3: order_id=103, amount=-15.00, region=West | Row4: order_id=104, amount=4200.00, region=South | Row5: order_id=105, amount=45.75, region=East | Row6: order_id=106, amount=39.20, region=West Column descriptions: amount = order total in USD, typically between $10 and $150 for this product line Known exceptions: none provided

When to use it

  • You've just received a new dataset and want a quick sanity check before building any analysis on top of it
  • You're reviewing transaction or expense data and want a first pass at flagging unusual amounts for manual review
  • You suspect a sensor, form, or data pipeline is occasionally logging bad values and want them surfaced
  • You're preparing a dataset for a model and need obvious outliers identified before deciding whether to cap, remove, or keep them

Best practices

  • Paste actual rows of data, not just column names and a description — the model can only reason about values it can see
  • Tell the model what each column represents (units, expected range) so it doesn't flag a legitimately large value, like an enterprise deal size, as an error
  • Ask for outliers to be split into likely data-entry errors versus statistically unusual-but-valid values, since they need different next steps
  • Request that findings reference specific row numbers or IDs so you can go back and verify each flagged value against the source

Common mistakes

  • Pasting a huge raw file and expecting exhaustive row-by-row analysis — models work best on a sample or a clearly bounded set of rows
  • Not specifying the expected range or unit for a column, which leads the model to guess at what counts as "normal"
  • Treating the model's flagged outliers as a final decision instead of a starting list for manual review
  • Skipping context about known exceptions (e.g. "Q4 numbers are always higher due to holiday sales") that would otherwise get flagged as anomalies

FAQs

How do I find outliers in a dataset using ChatGPT?

Paste the actual rows along with a description of each column's expected range or units, then ask the model to flag values outside that range and explain why. Giving it real data to reason over, rather than just a description, produces far more useful results.

What's the difference between a data-entry error and a statistical outlier?

A data-entry error is an impossible or clearly wrong value, like a negative age or a date in the future. A statistical outlier is a value that's unusually high or low but still plausible, like one large order among many small ones — these need different follow-up.

Can AI detect anomalies in a large CSV file automatically?

Models handle a bounded sample of rows well but aren't a substitute for statistical anomaly-detection methods on very large datasets. Use this kind of prompt for a first-pass review or a sample, then apply proper statistical or ML methods for full-scale detection.

Why did the model flag a value that's actually correct?

Usually because it wasn't told about a known pattern, like a seasonal spike or an intentionally large enterprise order. Listing known exceptions in the prompt upfront prevents the model from misflagging legitimate values.

What tool pairs well with this prompt when working from a large data file?

Context Extractor — it pulls just the relevant columns or rows from a large CSV or spreadsheet first, so this outlier-detection prompt works from a focused, clean slice of data instead of an entire raw file.

Found this prompt useful? Share it.

Share

More in Data Analysis & Data Science

Data Analysis & Data Science

AI Prompt to Explore and Summarize a Snowflake Dataset via Snowflake's MCP Server

This AI prompt is for analysts and data scientists who want a fast first pass over an unfamiliar table in Snowflake , using Snowflake's MCP…

ROLE: You are a data analyst assistant helping profile an unfamiliar database table before analysis.

CONTEXT:
- Table name: [SCHEMA.TABLE_NAME]
- Analysis goal: [WHAT YOU ARE TRYING TO ANSWER OR BUILD WITH THIS DATA]
- Schema: [LIST COLUMN NAMES AND DATA TYPES]
- Sample rows: [PASTE 10-20 SAMPLE ROWS]
- Row count and known constraints: [TOTAL ROW COUNT, ANY KNOWN PRIMARY/FOREIGN KEYS]

TASK:
1. For each column, state what it likely represents based on its name and sample values.
2. Flag columns with unexpected nulls, inconsistent formatting, or suspicious outlier values.
3. Identify which columns are most relevant to the stated analysis goal.
4. Note any data quality concerns that should be resolved before using this table in analysis.

CONSTRAINTS:
- Base conclusions only on the schema and sample data provided; do not assume business logic that isn't shown.
- Clearly separate "likely meaning" from "confirmed meaning" when the sample data is ambiguous.

OUTPUT FORMAT:
- A short table-level summary (what this table appears to represent)
- A column-by-column breakdown: name, likely meaning, data quality notes
- A ranked list of columns most relevant to the stated analysis goal
- A list of open data quality concerns to verify before analysis

Make this prompt yours

Data Analysis & Data Science

AI Prompt to Audit BigQuery Query Costs Using Google Cloud's MCP Server

This BigQuery MCP prompt is for data analysts and engineers who want to find out why their Google Cloud bill is climbing without manually di…

ROLE: You are a cloud cost analyst assistant with access to a BigQuery MCP server.

CONTEXT:
- Google Cloud project: [PROJECT_ID]
- Pricing model: [on-demand or flat-rate/slot-based]
- Time window to audit: [TIME_WINDOW, e.g. last 7 days]
- Cost or bytes-scanned threshold to flag: [THRESHOLD]

TASK:
1. Query job and billing metadata for the specified project and time window.
2. Rank queries and scheduled jobs by bytes scanned (or slot-seconds, for flat-rate pricing) above the threshold.
3. Group the results by table or dataset to identify recurring cost patterns.
4. For each high-cost pattern, identify the likely cause (e.g. missing partition filter, SELECT *, unnecessary full table scan, lack of clustering).
5. Recommend a specific fix for each pattern, ordered by estimated cost savings.

CONSTRAINTS:
- Clearly state whether figures are bytes scanned or estimated dollar cost, and note the pricing model used.
- Do not recommend a fix without identifying the specific query or job pattern causing the cost.

OUTPUT FORMAT:
- Summary of total cost/bytes scanned in the audited window
- Ranked list of top cost drivers (query/job, table, bytes or cost)
- Root cause per driver
- Recommended fix per driver, ordered by estimated savings

Make this prompt yours

Data Analysis & Data Science

ChatGPT Prompt to Analyze Open-Ended Survey Responses

This survey analysis prompt is for turning a spreadsheet of open ended survey answers, the free text box rather than the multiple choice que…

ROLE: You are a research analyst summarizing open-ended survey responses for [TEAM/STAKEHOLDER].

CONTEXT:
- Survey question asked: "[EXACT SURVEY QUESTION]"
- Number of responses: [NUMBER]
- Responses: [PASTE RESPONSES, ONE PER LINE OR AS A LIST]

TASK:
1. Group the responses into [NUMBER, E.G. 5-8] distinct themes based on what respondents actually said.
2. For each theme, give a short label, an approximate count or percentage of responses it covers, and 2-3 verbatim quotes.
3. Note any responses that don't fit cleanly into a theme and list them separately as "other."
4. Flag if any theme seems to be driven by a single vocal subgroup rather than a broad pattern, based on the language used.

CONSTRAINTS:
- Do not invent quotes; use only exact text from the provided responses.
- Do not merge themes that are related but distinct, e.g. "price too high" and "unclear pricing page" should stay separate.

OUTPUT FORMAT:
A table (Theme | Approx. Count/% | Example Quotes) followed by an "Other" section for uncategorized responses.

Make this prompt yours