Menu

1 / 2

AI-Generated Code Looked Right, but the Data Was Wrong

DEV Community·Piotr·6 months ago
#4bu1Mc4t
#ai#python#datascience#code#output
Reading 0:00
15s threshold

I'm working on an AI Data Analyst in MLJAR Studio.

The idea is simple: you ask a question in natural language, AI writes Python code, executes it, and shows the result.

But recently I found a small example that reminded me why AI data analysis needs more than code generation.

The code worked

I was testing a medical data analysis use case with a diabetes CSV file.

The first task was simple:

load data from this URL

AI generated Pandas code with read_csv() .

The code executed without errors.

The dataframe was displayed.

The shape looked correct: 768 rows and 9 columns.

So everything looked fine.

But then I looked at the dataframe.

148 pregnancies?

In the first row, the Pregnancies column had value 148 .

That immediately looked wrong.

Values like 0 , 1 , 2 , 6 , or 8 make sense for number of pregnancies.

But 148 ?

No.

Then I noticed more strange things:

Pregnancies had values like 148 , 85 , 183

Age had values like 0 and 1

Outcome was empty

the whole dataframe looked shifted

The code…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.