The debugging page for the AI build. Lab 10, the capstone, and anything in between.
You asked the AI to build something, and it is broken. That is normal. Almost every
build breaks at some point, including mine. This page is the way through: first the six failures we
can predict, then the five prompts that fix almost everything else.
Before anything else, breathe
Your fallback is the Lab 10 dashboard template. It opens by double-click, embeds its data, and already
draws, so if your build is a mess, go back to the template and fill in the blanks again. You are
not building from nothing.
You have permission to switch paths. Lab 10 takes either a single-file HTML page or a
Colab notebook, at equal credit. If the browser build is fighting you, do the clustering and the
chart in Colab, screenshot the chart, and submit the image plus the notebook. Switching is not a
setback, because the clustering and the interpretation are the graded work, not the container
they arrive in.
The six failures we predict
Most stuck builds in this course are one of these. Check them before you start
prompting. To see the console: press F12 in your browser, then click the Console tab.
Red lines are errors.
1. Your clusters just split on one feature
K-means groups rows by distance, so a feature with a bigger numeric range can
dominate the fit unless the features are scaled first. The tell is a scatter where the groups are
bands along one axis, usually the column with the largest values, while the other features may as
well not be there.
The fix. Scale before you fit. Tell the AI: standardize the features with
StandardScaler before running k-means, then refit. The groups should start reflecting
behavior across all the features rather than the size of one.
2. You picked k blind, and the story keeps changing
There is no accuracy score to tell you the right k, so a k chosen once and never
questioned is a guess. If the segments look different every rerun, or you cannot say what a group
is in one sentence, the k you picked is probably not supporting a stable story.
The fix. Try a few values, such as 2 through 5, and look at the picture
each time. Prefer the k where the groups stay put across reruns and each one can be described in a
sentence, because the picture and its stability are the check when there is no metric to decide
for you.
3. fetch() dies on file://
You open your page by double-clicking the file, so it runs on
file://, not a web server. Browsers block fetch() of local files there.
If the AI wrote code that fetches your CSV at runtime, it works on the AI's imagined server and
fails on your desktop.
The fix. Embed the data in the file as a JavaScript string and parse it
there. The template already does this. Tell the AI: do not fetch anything at runtime, embed the
CSV in the page the way the template does.
4. The chart never renders, and the console shows the CDN script failed
The page loads its chart library from a CDN with one script tag. If that tag has a
typo in the URL, or you are offline, the library never arrives and nothing draws. The console line
usually says ERR_NAME_NOT_RESOLVED, a 404, or echarts is not defined.
The fix. Check the script tag URL character by character against the
template's. Check you are online. If you need the page to work offline, ask the AI to inline the
library into the file instead of loading it from the CDN.
5. The AI clustered on the label, and one segment is suspiciously perfect
If bad_ar was left in the feature set, the algorithm grouped on the
answer, so the discovery is just the label read back to you. The tell is a segment whose default
rate is near 1.0 while the others sit near 0, which real behavior features rarely produce.
The fix. Refit on the behavior features only, with bad_ar
excluded. The label comes back afterward as the verification step: check whether the risky
customers concentrate in one of the segments the behavior found.
6. You built in Colab, and there is no .html file to submit
The Colab path ends in a notebook, not a web page. That is expected, not a
problem with your build.
The fix. Screenshot the chart and submit the image plus the notebook. The
Lab 10 instructions allow this path at equal credit, so nothing needs converting to HTML.
The debugging prompt bank
Five prompts, in the order you usually need them. One pattern runs through all of
them: give the AI something concrete, a full error message, a specific symptom, an expected number.
The more concrete the prompt, the more specific the fix that comes back. The loop is usually
describe, fix, test, repeat.
1Got an error
Reach for this the moment anything errors. Paste the complete message, do not summarize it.
The script has an error. Here is the full error message:
[paste: the complete error output, including the traceback or the browser console line]
Please fix it.
2Try a different approach
Reach for this when the first fix did not work. Saying so plainly stops the AI from retrying the same idea.
That did not fix it. The same problem is still happening: [describe exactly what you still see]. Try a different approach.
3Explain what you changed
Reach for this after any fix, before you move on. You own every number your tool shows, so you need to know what moved.
Explain what you changed and why. Keep it short, and tell me which parts of the output could be affected by the change.
4Add logging
Reach for this when the failure is silent, no error, just wrong or missing output. Logging turns an invisible problem into something you can paste back into prompt 1.
Add logging so we can see what is happening. Print [the row counts / the parsed values / each step's output] as it runs, so we can find the step where it goes wrong.
5Make it tie out
Reach for this when the tool runs but a number disagrees with a value you trust, a hand calculation, a pivot table, a provided answer. State both numbers and make the AI reconcile them.
This output does not tie out. With inputs [state the exact inputs], the correct value is [expected number], but the tool shows [shown number]. Do not change the expected value. Trace the calculation step by step, find where the two diverge, and fix the code so the output ties out.
When the loop stalls. Two rounds of prompt 1 and prompt 2 with no
progress usually means the AI cannot see the problem. Use prompt 4 to give it more to look at, then
start the loop again. These five prompts are part of the course AI Kit. They work with any AI and
any project, and they leave with you.
Still stuck
Paste your error below, then open the Ask AI tutor on this page. The tutor reads
what you paste here, so it can help with your actual error, not a generic one. And if you are still
stuck after that, message me. A five-minute question can save you an evening.
Nothing you paste here leaves this page except through the tutor conversation you start.
Your fallback is always the
Lab 10 skeleton notebook. It opens in Colab
with the data-loading cell already there. Fill in the rest and it is your notebook.