Evaluating LLM Capabilities in Data Analysis and Programming Tasks

    This article presents a practical framework for evaluating large language models in data analysis and programming scenarios. It moves beyond subjective impressions to examine instruction following, data insight, anomaly handling, reasoning-trace readability, code correctness and reproducibility, and reusable evaluation workflows. It also outlines prompt design and human review practices that help developers obtain more reliable, auditable, and maintainable results.

    When using large language models for data analysis or programming assistance, a model that “looks smart” is not necessarily genuinely useful. Some models can quickly generate complete code while ignoring the user’s actual question. Some provide comprehensive answers but become fixated on anomalous data points. Others output large amounts of internal reasoning traces and may even get stuck in repetitive loops while executing code. For developers, evaluating a model should not depend only on whether its response is fluent. More important is whether it can accurately understand the task, identify uncertainty, validate conclusions, and deliver results in a readable and reproducible form.

    1. From Subjective Impressions to Task-Dimension Evaluation

    Model experience is often highly subjective. Some users care more about response speed, some prioritize code correctness, and others focus on whether the model can proactively identify implicit conditions in a request. To avoid making “feels comfortable to use” the only criterion, evaluation can be broken down into the following dimensions.

    1.1 Instruction Following

    Instruction following is not just “producing output as requested.” It also includes understanding constraints, identifying task goals, and avoiding unauthorized changes to the problem.

    For example, a user may require the model to:

    • Analyze only the existing data and not synthesize samples;
    • Not directly delete outliers;
    • Provide statistical conclusions before code;
    • Ensure that the code can run independently;
    • Explicitly state when the evidence is insufficient for unconfirmed conclusions.

    A qualified model should satisfy all of these conditions at the same time, rather than completing only the easiest one. Especially in complex tasks, a model may reinterpret “explaining the data” as “correcting the data,” or turn “exploring trends” directly into “fitting a forecast,” causing the analysis objective to drift.

    1.2 Data Insight

    Time-series data often contains trends, cycles, abrupt changes, noise, missing values, and measurement errors. If a model focuses only on the largest numerical jump, it can easily misclassify a local anomaly as an overall pattern.

    A more reliable analysis process should include:

    1. Checking whether the time field is continuous and whether duplicate records exist;
    2. Observing data units, value ranges, and missing values;
    3. Distinguishing single-point anomalies, continuous abrupt changes, and structural changes;
    4. Judging whether anomalies have practical significance in light of business context;
    5. Using rolling statistics, differencing, or segmented analysis to validate conclusions;
    6. Clearly distinguishing “phenomena observed in the data” from “speculation about those phenomena.”

    When analyzing data with large jumps, a model should not draw conclusions based on a single extreme value. For example, a sudden rise at a certain time point may be caused by sampling error, device switching, environmental changes, or a real event. Without context, the model should list the possibilities and request additional information rather than forcing a single explanation.

    2. Why Models Tend to Become “Stubborn” About Anomalies

    LLM answer generation fundamentally relies on pattern matching and contextual inference. When input data contains obvious jumps, models often prioritize the most visually salient feature and organize the entire analysis around it. This behavior has three common causes.

    First, models tend to seek a narrative that can explain most phenomena. Even when the data is insufficient to support a single conclusion, a model may fill in a seemingly reasonable cause in order to keep the response complete.

    Second, a model may not have genuine reflective capacity when corrected by a user. If the user only says “this conclusion is wrong,” the model may simply rephrase the original judgment instead of rechecking the data basis.

    Third, in long contexts, a model may over-rely on hypotheses formed earlier. Once it has judged a certain point as a trend change early on, subsequent analysis may revolve around that judgment, forming an incorrect reasoning chain.

    To address these problems, prompts should not merely ask the model to “think again.” They should require specific verification actions. For example:

    • Compare the raw data, data with outliers removed, and segmented data separately;
    • List evidence supporting and opposing the current conclusion;
    • Mark which content is fact and which is assumption;
    • If evidence is insufficient, provide at least two explanations;
    • Output data quality check results before drawing a conclusion.

    This approach is more effective than broadly asking the model to “analyze deeply,” because it turns reflection into checkable steps.

    3. Reasoning-Trace Readability and Verifiable Conclusions

    In some AI tools, a model may organize intermediate reasoning in English or a mixed language and then convert it into Chinese output. For users, this can cause unnatural phrasing, logical jumps, and inconsistent terminology translation.

    In practical work, it is not always necessary to display the model’s full internal reasoning process. What is more valuable is requiring the model to provide a structured “analysis basis,” such as:

    • Data observations: list phenomena seen directly from the data;
    • Method description: explain which statistical methods were used;
    • Key evidence: provide metrics or intervals that support the conclusion;
    • Uncertainty: explain which factors remain unconfirmed;
    • Final conclusion: answer the original question in concise language;
    • Next steps: explain what additional data or experiments are needed.

    This output format improves readability and makes human review easier. In enterprise scenarios, conclusions that can be reviewed are usually more important than lengthy reasoning text. Especially in high-risk fields such as finance, manufacturing, healthcare, and security, models should avoid packaging unverified speculation as established fact.

    4. Code Generation Ability Cannot Be Judged Only by “Whether It Runs”

    When models generate code, the common problem is not syntax errors but logic errors and incomplete delivery.

    For example, a model may:

    • Write a large amount of code immediately without first confirming the data structure;
    • Generate charts but fail to embed the chart results in the final report;
    • Produce code that runs successfully but does not explain the output metrics;
    • Lack exit conditions in loops or retry logic;
    • Use methods unsuitable for the current data scale;
    • Generate scripts with unclear dependencies that cannot be reproduced in the environment.

    Therefore, evaluating code ability should check at least four levels.

    4.1 Correctness

    Whether the code can handle normal input, empty data, missing values, and outliers. It should not be validated with only one ideal sample.

    4.2 Explainability

    Whether variable naming, function boundaries, and comments are clear. The code should allow other developers to quickly locate data reading, cleaning, analysis, and output stages.

    4.3 Reproducibility

    Whether the runtime environment, input format, and necessary dependencies are specified. For charts and statistical results, the generation process should also be retained rather than showing only the final conclusion.

    4.4 Safe Exit

    All loops should have clear termination conditions. Network requests and external calls should have timeouts and retry limits. Exception branches should be able to return understandable error messages.

    A practical prompt template for a code task can be:

    1. Please do not write code yet. First confirm:
    2. 1. Input data fields and their meanings;
    3. 2. Task objective and evaluation metrics;
    4. 3. Possible missing values and outliers;
    5. 4. Tables or charts to be generated;
    6. 5. Code runtime environment.
    7. After confirmation, output step by step:
    8. - Data inspection code;
    9. - Analysis code;
    10. - Visualization code;
    11. - Result interpretation;
    12. - Edge cases and risk notes.

    Delivering in stages can reduce the tendency of models to “head down and start writing code” immediately, and it also makes it easier for users to correct the direction early.

    5. Building a Reusable Model Evaluation Process

    If multiple models or multiple versions are to be compared, it is advisable to use fixed data, fixed tasks, and fixed scoring criteria rather than trying them out in turn based on impressions.

    A basic evaluation set can include:

    1. Simple statistical tasks: mean, quantiles, missing-value statistics;
    2. Time-series tasks: trend, cycle, abrupt change, and anomaly identification;
    3. Explanation tasks: writing a short analysis report based on results;
    4. Programming tasks: generating data cleaning and visualization scripts;
    5. Debugging tasks: fixing code that contains boundary errors;
    6. Counterfactual tasks: requiring the model to explain whether conclusions hold under different assumptions.

    A five-level scoring scale can be applied to the following criteria:

    • Instruction following: whether all constraints are satisfied;
    • Factual accuracy: whether there are obvious errors;
    • Data rigor: whether observations and speculation are distinguished;
    • Code quality: whether the code is runnable and maintainable;
    • Expression quality: whether it is clear, concise, and easy to review;
    • Delivery completeness: whether it includes the results the user actually needs.

    In addition, response speed, failure types, and manual correction cost should be recorded. A model that responds quickly but requires extensive rework may not be more efficient overall. A model that responds slightly more slowly but proactively exposes uncertainty may be more suitable for production environments.

    6. How Developers Can Improve Results

    Model capabilities have boundaries, and a reasonable workflow is more important than simply switching models.

    First, provide structured input. Write the objective, data description, constraints, output format, and acceptance criteria separately and clearly to reduce the model’s need to guess.

    Second, ask the model to restate the task. If the restatement does not match the actual objective, correct it immediately before code generation or data analysis.

    Third, adopt a “small-step validation” strategy. First ask the model to inspect the data, then ask it to propose an analysis plan, and only finally generate the complete code and report.

    Finally, maintain human review. Particular attention should be paid to outlier explanations, causal judgments, statistical significance, code boundaries, and security risks. Models can improve analysis efficiency, but they cannot replace domain experts’ confirmation of key conclusions.

    Overall, differences among large language models in data analysis and programming scenarios are often reflected not only in knowledge coverage, but also in task understanding, anomaly handling, reflection mechanisms, code delivery, and expression style. A truly trustworthy tool is not the one that sounds smartest. It is the one that remains restrained when uncertain, proactively verifies anomalies, explains results after generating code, and makes the entire analysis process reproducible, auditable, and maintainable.