Improving with Feedback

Updated · 6 min read
mediumPython 3.13aiapplicationsfeedbackevaluationpandas

An AI application is never finished on launch day. Iteration is the cycle of collecting feedback, finding where the app fails, changing it and measuring again. Because the AI Learning Assistant stores every interaction with its rating, tokens and time, its own database shows where to improve.

The Improvement Cycle

Measure, find, fix, measure again
StepDescription
Collect feedbackIt is used to gather ratings, comments and real questions from use
Find mistakesIt is used to spot where ratings drop, answers are wrong or responses are slow
RefineIt is used to change prompts, retrieval, models or features to fix one problem
Evaluate againIt is used to check the change helped and didn't break anything else

Creating the Interaction Log

This program creates 300 made-up interactions like the ones app.py stores, with one problem hidden in them:

Python
import numpy as np
import pandas as pd
 
rng = np.random.default_rng(7)  # a fixed seed, so everyone gets the same data
n = 300
topics = ["fractions", "photosynthesis", "gravity", "the water cycle",
          "compound interest", "DNA", "supply and demand", "climate"]
log = pd.DataFrame({
    "topic": rng.choice(topics, n),
    "level": rng.choice(["beginner", "intermediate", "advanced"], n, p=[0.5, 0.3, 0.2]),
    "input_tokens": rng.integers(160, 220, n),
    "output_tokens": rng.integers(80, 160, n),
    "seconds": rng.gamma(4, 0.9, n).round(2),
})
# A hidden problem for the analysis to find: beginner answers on fractions are often rated down
chance_down = np.where((log["topic"] == "fractions") & (log["level"] == "beginner"), 0.6, 0.12)
log["rating"] = np.where(rng.random(n) < chance_down, -1, 1)
log.to_csv("interactions.csv", index=False)
print("Saved", len(log), "interactions")
Output
Saved 300 interactions

Example: Finding What to Fix

Python
import pandas as pd
 
log = pd.read_csv("interactions.csv")
PRICE_IN, PRICE_OUT = 4.00, 20.00  # US dollars per million tokens (a large model, November 2026)
log["cost"] = (log["input_tokens"] * PRICE_IN + log["output_tokens"] * PRICE_OUT) / 1_000_000
 
print("Interactions:", len(log))
print(f"Satisfaction: {(log['rating'] == 1).mean():.0%} thumbs up")
print(f"Response time: median {log['seconds'].median():.1f} s, slowest 10% over {log['seconds'].quantile(0.9):.1f} s")
print(f"Cost per interaction: ${log['cost'].mean():.4f}")
 
by_group = (log.assign(thumbs_down=log["rating"] == -1)
               .groupby(["topic", "level"])["thumbs_down"].agg(["mean", "count"]))
worst = by_group[by_group["count"] >= 5].sort_values("mean", ascending=False).head(3)
print("Most thumbs down (groups with 5+ answers):")
for (topic, level), row in worst.iterrows():
    print(f"  {topic:17} {level:12} {row['mean']:.0%} of {int(row['count'])}")
Output
Interactions: 300
Satisfaction: 87% thumbs up
Response time: median 3.1 s, slowest 10% over 5.7 s
Cost per interaction: $0.0031
Most thumbs down (groups with 5+ answers):
  fractions         beginner     58% of 19
  fractions         advanced     30% of 10
  climate           advanced     25% of 8

Explanation: The overall numbers look healthy: 87% thumbs up, a median wait of 3.1 seconds and about a third of a cent per answer. Grouping thumbs down by topic and level reveals the hidden problem: beginner answers about fractions are rated down 58% of the time. The next two groups have only 8 to 10 answers each, so their rates may just be chance. Groups with fewer than 5 answers are left out for the same reason.

From Finding to Fix

  1. Read the failing answers. Open the beginner fractions answers that were rated down: are they wrong, too advanced, or missing an example?
  2. Change one thing. For example, add to the beginner instruction: "Use whole numbers and food examples, such as pizza slices, before any rule."
  3. Evaluate again on a fixed set of beginner fractions questions, and check that other topics didn't get worse.
  4. Release and watch the thumbs-down rate for that group over the next weeks.

Common Mistakes

Looking only at the overall score. Break results down to find the groups that fail.

Reacting to tiny groups. A few ratings can swing wildly; wait for enough data.

Shipping a fix without re-evaluating. A prompt change can fix one topic and break another.

Interview Corner

How do you improve an AI application after launch?

Collect feedback and usage data, break it down to find where it fails, make one targeted change, evaluate it on fixed test cases, release it, and keep measuring.

Which metrics would you track for an AI tutoring app?

Answer accuracy, user satisfaction, response time, learning improvement (quiz scores over time) and cost per interaction, each broken down by topic and user group.

Practice

Exercise: find the slow answers. Extend the analysis to print the median seconds per level and the three slowest topics. Is any group slow enough that students would notice? What could you change to speed it up?

Check your understanding:

  1. What was the overall satisfaction?
  2. Which group stood out, and why trust it more than the others?
  3. Why change one thing at a time?

Quick check: improving with feedback

4 questions
1Which group had the most thumbs down?
2Why can 87% overall hide a problem?
3Why be careful with "climate, advanced, 25% of 8"?
4What comes right after making a fix?

Key Takeaways

Quick reference

MeasureFrom the database
SatisfactionShare of rating == 1
Response timeMedian and slowest 10% of seconds
CostTokens × price, averaged
Problem areasThumbs down by topic and level

Was this tutorial helpful?

Lesson 186 of 186