top of page

How to classify review sentiment with Claude and check the labels

2 minutes ago
10 min read
Cover showing the title How to classify review sentiment with Claude and check the labels on a teal data skyline background. Data Studios original cover

Claude can label a file of customer reviews as positive, negative, neutral or mixed when the analyst uploads it as a CSV and asks for a labeled copy back, and the labels are only as useful as the check that follows. Anthropic's help pages, verified on November 26, 2026, list CSV among the supported upload types, describe a code execution and file creation feature that runs Python in a sandbox on every Claude plan, and set a 30 MB limit per file for that feature. They say nothing about sentiment accuracy, so the quality of the output has to be measured by the analyst against a sample labeled by a person.


The task looks simple and fails in predictable places. Sarcasm reads as praise, a review that complains about delivery gets counted against the product, a sentence with "but" in the middle hides two opinions, and star ratings disagree with the text more often than most dashboards assume. In the 16-review illustrative sample used below, the star rating points to a different sentiment from the text in 6 cases, and the product with the highest average rating has the lowest net sentiment.


The method is the same at any size. Upload the file, ask for a fixed label set with a reason for each label, get a CSV back, compare it with a human-labeled sample in Python, and only then publish counts or charts.


··········


WHAT CLAUDE NEEDS FOR SENTIMENT ANALYSIS ON A REVIEW FILE.


Two Anthropic help pages cover the mechanics. The "Upload files to Claude" article, last updated July 23, 2026, lists PDF, DOCX, CSV, TXT, HTML, ODT, RTF, EPUB, JSON and XLSX as document types, notes that XLSX uploads require code execution and file creation to be enabled, and states that Claude extracts text only from these files. The "Create and edit files with Claude" article says code execution and file creation is available to Free, Pro, Max, Ultra, Team and Enterprise users on the web, Claude Desktop and Claude Mobile, that Claude can write Python scripts for data analysis, and that CSV and TSV files can be uploaded for data analysis and visualization.


........


Item

What Anthropic documents

Practical effect

Upload types

CSV, TSV, XLSX, JSON, TXT and others

Export reviews as CSV with an ID column

File limit, code execution

30 MB per file, uploads and downloads

Split larger exports by month or product

Chat upload limits

500 MB per file, up to 20 files per chat

Higher than the code execution limit

Project files

30 MB per file, text extraction only

Use a chat for Python analysis

Plans

Free, Pro, Max, Ultra, Team, Enterprise

Available on every plan

Default setting

On for individual plans; owners can disable it on Team and Enterprise

Check Settings > Capabilities

Network access

On for individual plans; off by default on Enterprise

Packages may be limited to pre-installed ones

Usage

Draws from plan limits, uses more than normal chats

Large files consume more of the allowance


........


The setting is called "Code execution and file creation" in Settings > Capabilities for individual plans, labeled "Create and edit files" in the updated settings layout, and sits under Organization settings > Capabilities for Team and Enterprise owners. Anthropic does not publish a list of pre-installed Python packages, a row limit or a fixed context window figure on these pages, so the safe assumption is that pandas-style work is possible while any specific library has to be confirmed in the chat.


The two pages give different file size figures, and the difference has a practical reading. The 500 MB figure applies to chat uploads in general, while the 30 MB figure is the one Anthropic ties to code execution and file creation, which is the mode that writes a labeled CSV back. For a review export, plan around 30 MB.


··········


THE ILLUSTRATIVE REVIEW DATASET AND THE HUMAN LABELS.


The sample below is invented for this walkthrough and contains no real customer data. It has 16 reviews of three kitchen products, a star rating and a label assigned by a person using four classes: positive, negative, neutral (no opinion, or a factual statement) and mixed (a clear positive and a clear negative about the product in the same review).


........


review_id

product

stars

review_text

human_label

1

Blender X2

5

Quiet motor and the smoothies come out silky. Best purchase this year.

positive

2

Blender X2

2

Lid cracked after two weeks and support never replied.

negative

3

Blender X2

4

Works fine, nothing special. Does the job.

neutral

4

Blender X2

5

Oh great, another blender that leaks all over the counter.

negative

5

Blender X2

3

Powerful motor, but it is far too loud for early mornings.

mixed

6

Kettle K1

5

Boils fast and switches off on time. Love the design.

positive

7

Kettle K1

1

Arrived with a dent. Refund took a month.

negative

8

Kettle K1

4

Not bad at all, I would buy it again.

positive

9

Kettle K1

3

Delivered on Tuesday as promised.

neutral

10

Kettle K1

2

Looks nice, but the handle gets hot and the lid sticks.

mixed

11

Toaster T3

5

Even browning on both sides, easy to clean.

positive

12

Toaster T3

4

Toasts well, though the crumb tray is flimsy.

mixed

13

Toaster T3

1

Stopped heating after three uses.

negative

14

Toaster T3

5

Never had a toaster this bad. Burned every slice.

negative

15

Toaster T3

3

It toasts bread.

neutral

16

Toaster T3

4

Fast, consistent and cheaper than the old one.

positive


........


Several rows are traps on purpose. Review 4 is sarcastic, review 8 uses a double negative that is positive, review 14 carries five stars on a text that is plainly negative, review 9 is about delivery and carries no opinion of the kettle, and reviews 5, 10 and 12 each hold one compliment and one complaint.


··········


THE PROMPT FOR CLASSIFYING REVIEW SENTIMENT WITH CLAUDE.


A good prompt fixes the label set, defines each label, forces one label per row, keeps the original ID and asks for a file. A short reason column makes disagreements easy to audit later, and an instruction to ignore the star rating keeps the label tied to the text.


I uploaded reviews_sample.csv with columns review_id, product, stars, review_text.
Classify the sentiment of review_text toward the product for every row.

Use exactly one of these labels:
- positive: the reviewer is satisfied with the product
- negative: the reviewer is dissatisfied with the product
- neutral: no opinion about the product, or a purely factual statement
- mixed: at least one clear positive and one clear negative about the product

Rules:
- Base the label on review_text only. Do not use the stars column.
- Treat sarcasm according to its intended meaning.
- Comments about delivery or packaging alone count as neutral toward the product.
- Return a CSV named claude_labels.csv with columns review_id, label, reason.
- Keep every review_id exactly once, in the original order. Reason: max 12 words.
- After writing the file, report the row count and the count per label.

For files that are too long to read comfortably in one pass, a second instruction asks Claude to process the file in batches by review_id and to confirm the row count of the final file. The row count it reports is a claim to verify, which the check script below does.


The same labeling job can run inside a warehouse or a spreadsheet when the reviews already live there. The site has covered the SQL route in classifying text with Snowflake Cortex AI_CLASSIFY and the spreadsheet route in categorizing text with Fill with Gemini in Google Sheets; the checking method below applies to both.


··········


EXPECTED SENTIMENT RESULTS FOR THE SAMPLE, COMPUTED IN PYTHON.


The figures below come from the human labels and were computed with pandas. They are the reference a correct run should reproduce on this file. Net sentiment is defined here as positive reviews minus negative reviews, divided by all reviews, times 100.


........


Product

Reviews

Positive

Negative

Neutral

Mixed

Net sentiment

Avg stars

Blender X2

5

1

2

1

1

-20.0

3.80

Kettle K1

5

2

1

1

1

20.0

3.00

Toaster T3

6

2

2

1

1

0.0

3.67

All products

16

5

5

3

3

0.0

3.50


........


The blender has the highest average rating of the three and the lowest net sentiment, and the kettle is the reverse. A dashboard built on stars alone would rank the products in the opposite order from one built on the text.


A star proxy (4 or 5 stars positive, 3 neutral, 1 or 2 negative) agrees with the human label on 10 of 16 reviews, or 62.5%. The six disagreements are reviews 3, 4, 5, 10, 12 and 14, which are the lukewarm, sarcastic, mixed and five-star negative cases, so the proxy fails where the text carries the most information.


··········


CHECKING CLAUDE'S SENTIMENT LABELS AGAINST THE HUMAN SAMPLE.


The script below reads the original file and the labeled file returned by Claude, checks that every review was labeled once with an allowed label, and reports accuracy, a confusion matrix and the list of disagreements. It runs in any local Python environment with pandas, and it can also be pasted into the same Claude chat.


import pandas as pd

ALLOWED = {"positive", "negative", "neutral", "mixed"}

gold = pd.read_csv("reviews_sample.csv")
pred = pd.read_csv("claude_labels.csv")  # columns: review_id, label

# 1. Structural checks: every review labeled once, only allowed labels
assert pred["review_id"].is_unique, "duplicate review_id in labels"
missing = set(gold["review_id"]) - set(pred["review_id"])
extra = set(pred["review_id"]) - set(gold["review_id"])
bad = set(pred["label"].str.strip().str.lower()) - ALLOWED
print("missing:", sorted(missing), "extra:", sorted(extra), "bad labels:", sorted(bad))

# 2. Agreement with the human labels
m = gold.merge(pred, on="review_id", how="inner")
m["label"] = m["label"].str.strip().str.lower()
acc = (m["label"] == m["human_label"]).mean()
print(f"accuracy: {acc:.2%} on {len(m)} reviews")
print(pd.crosstab(m["human_label"], m["label"], rownames=["human"], colnames=["claude"]))
print(m.loc[m["label"] != m["human_label"], ["review_id", "stars", "human_label", "label"]].to_string(index=False))

To show what the output looks like, the script was run on a test file built by hand from the human labels with three of them deliberately changed to positive: reviews 4, 12 and 14, the sarcastic one, one mixed one and the five-star negative one. The test file was made by hand and contains no Claude output. It reported no missing, extra or invalid labels, an accuracy of 81.25% on 16 reviews, and the three disagreements by ID, with all three errors falling in the positive column of the confusion matrix. A real run that puts its errors in one column the same way points to a systematic bias, and the prompt definitions for that class need tightening.


On a real file nobody labels everything by hand. The practical approach is to draw a random sample with a fixed seed, label it blind before looking at Claude's labels, and compare. With an observed accuracy near 90%, the 95% margin of error computed with the normal approximation is about 5.9 percentage points on 100 labeled reviews, 4.2 on 200 and 2.9 on 400, which gives a sense of how large the check sample needs to be.


sample = gold.sample(n=200, random_state=42)  # label these by hand, blind
sample[["review_id", "review_text"]].to_csv("to_label.csv", index=False)

The same discipline of recomputing the figure yourself applies to other statistical work in a chat, as in analyzing an A/B test with Claude and verifying the p-value.


··········


WHERE AI SENTIMENT LABELS USUALLY GO WRONG.


Sarcasm and irony are the classic failure, because the words are positive and the meaning is negative. Review 4 opens with "Oh great" and describes a leak, and any model that weighs vocabulary over meaning will call it positive.


Mixed reviews collapse into one side. When a review praises the motor and complains about the noise, a model asked for a single label often picks the clause that comes last or the one with stronger words. Keeping an explicit mixed class, and defining it, is the simplest fix; dropping it forces those reviews into positive or negative and inflates both.


Target confusion turns delivery, price or customer-service comments into product sentiment. If the business question is about the product, the prompt has to say so, and the reason column shows whether the instruction was followed.


Star leakage happens when the rating column is visible and the model leans on it. The five-star negative review 14 is the test case. Removing the stars column from the uploaded file is a stronger guard than an instruction to ignore it.


Silent row loss is the last risk. On long files, rows can be skipped, duplicated or relabeled with a different ID, which is why the script checks IDs before it computes any accuracy. Splitting large files follows the same logic as working past file limits in other assistants, covered in analyzing a CSV over ChatGPT's 50 MB limit with chunks and samples.


··········


DATA PRIVACY AND ADMIN SETTINGS FOR REVIEW FILES IN CLAUDE.


Customer reviews often contain names, order numbers and email addresses, and the two help pages do not state retention periods or training terms; they point to Anthropic's Privacy Policy and Commercial Terms. Removing personal fields before upload, keeping only review_id, product and text, reduces what leaves the company regardless of plan.


Anthropic's file creation page describes the code as running in an isolated, sandboxed container, says sandbox environments are never shared between users, and lists network egress options for Team and Enterprise owners: off, package managers only, package managers plus an allowlist of domains, or all domains, which the page calls the riskiest option. The same page warns that instructions hidden in external files or websites can try to make Claude run untrusted code or leak data, that disabling network access stops sandbox code from sending data out while connectors can still send data, and recommends watching Claude while it works and stopping it if it accesses data unexpectedly. Review text written by the public is exactly the kind of external content that warning describes.


The decision that stays human is what the labels are used for. A count of negative reviews per product is a reasonable automated output once the sample check passes; a decision about a supplier, a refund policy or an individual employee named in a review needs a person to read the reviews behind the number. Earlier coverage of Claude's spreadsheet and CSV upload features and limits describes the wider file workflow.


··········


CLAUDE REVIEW SENTIMENT LABELS: WHAT TO CONFIRM BEFORE YOU REPORT THEM.


Anthropic documents the pieces this workflow needs: CSV uploads, Python execution in a sandbox on every plan, a 30 MB per-file limit for code execution and file creation, and admin controls over the feature and its network access. It does not document sentiment accuracy, a row limit, the Python packages available or retention terms on the pages checked, and the feature can be switched off by Team and Enterprise owners, so availability depends on the organization's settings.


The checks are cheap. A fixed four-label scheme with definitions, a reason column, a file without star ratings or personal data, an ID check on the returned file and a blind human sample of 100 to 400 reviews are enough to know whether the labels can be trusted. In the illustrative sample, stars and text disagreed on 6 of 16 reviews and ranked the products in opposite orders, which is the gap a verified text label is meant to close.


··········


FOLLOW US FOR MORE.


·····


DATA STUDIOS


·····


datastudios.org


bottom of page