Answer A
“Best model wins”
- Gradient boosting, with scaling
- SMOTE oversampling
- Accuracy as the only metric
- No way to explain a prediction
Vibe coding · data science 規則
An assistant will write a whole notebook from one sentence. Whether the number at the bottom means anything depends on what that sentence left out. These are the rules I teach for closing those gaps before any code exists.
Send the prompt below to three assistants, or to the same one three times. You get three notebooks back, and all of them run.
Build a classifier for this CSV: https://…/data.csv
None of it is wrong code. Each notebook answers a different question, and none of them is the question you had in mind. The assistant filled every gap in the prompt with a guess. The rules below take the guesses away, one gap at a time.
Answer A
Answer B
Answer C
Rule 01
The same request comes back as notebook cells in Colab and as a script on a laptop. Say where the code will run and what the answer has to look like: cells or files, how packages get installed, where plots go.
Write the code to train a model on this data.
Notebook code pasted into a script, or the reverse, is the usual reason a first answer does not run.
ENVIRONMENT
- Google Colab notebook, Python 3. pandas, scikit-learn and matplotlib are already installed.
- Give the code as separate cells, with a short markdown cell before each one.
- Install extra packages only if essential, with !pip install in the first cell.
- Read the data from its URL. No Google Drive, no local paths.
- Show plots inline. Rule 02
Say what the data is: where it lives, how many rows and columns, which column is the target and the type each column really has. Anything you leave out gets guessed, and the guesses are worst on columns that look like numbers and are not.
Here is a CSV with customer data.
DATA - Source: <URL or path>. <rows> rows, <columns> columns. - Target: "<column>" (<its values, and which one is the positive class>). - "<column>" is a code, not a quantity: treat it as categorical.
Rule 03
Without limits the assistant reaches for its favorite model, adds preprocessing nobody asked for and tunes whatever it likes. Name the model family, write the grid yourself and list what is off the table. Strict limits also keep results comparable when you run the same prompt in two tools.
Use the best model.
You decide the search space. The assistant writes the code that searches it.
MODEL SETUP (hard constraints)
- Use ONLY scikit-learn DecisionTreeClassifier.
- Search exactly this grid with GridSearchCV:
- max_depth: [2, 3, 4, 5, 6, 8, 10, 12]
- min_samples_leaf: [1, 5, 10, 20]
- criterion: ["gini", "entropy"]
- class_weight: [None, "balanced"]
- No other models, no feature scaling, no resampling, no PCA.
- random_state=42 everywhere. Rule 04
Leakage starts as soon as anything learns from test rows. The split comes before encoding, scaling, exploring or tuning, and every transformation is fitted on train only.
Preprocess the data and train a model.
VALIDATION RULES
- Split first: stratified 80/20 train/test with random_state=42, before any preprocessing.
- Fit every transformation (imputers, encoders, scalers) on train only. Rule 05
“Tune it” is an invitation to peek at the test set. Say which grid, which cross-validation and which score, and say where the decision threshold comes from. The test set gets opened once.
Optimize the hyperparameters.
If a number helped you choose, it cannot also be the number you report.
VALIDATION RULES
- Tune with GridSearchCV, 5-fold StratifiedKFold on train, scoring="roc_auc".
- Choose the decision threshold on out-of-fold predictions, never on test.
- Use the test set exactly once, at the end. Rule 06
On data where one row in twenty is positive, a model that always answers “no” is 95% accurate. State the goal in business terms, the metrics that reflect it and the baseline any model has to beat.
Make it accurate.
SUCCESS
- Goal: catch the positive cases, even at the cost of some false alarms.
- Report recall and precision for the positive class, ROC AUC and the confusion matrix.
- Always show the majority-class baseline next to accuracy. Rule 07
Output you can read and rerun is part of the spec. Ask for a short explanation before each block of code, results that were actually printed, and no new libraries without asking.
(nothing said)
A number in the prose that no cell printed is a claim. Ask for the cell.
WORKING STYLE
- Before each code block, 2–3 lines on what you will do and why.
- Print every key number. Never invent results.
- Ask before adding a library.
- In every answer, list the files you created or changed. Rule 08
Small steps can be reviewed. Ask for one step per answer and check it before you type “next”. When a rule is broken, name it and ask for the smallest fix. Do not start over.
Do everything end to end.
WORKING STYLE
- Do ONE step per answer and wait for me to say "next".
- If I say a rule is broken, redo only the affected code and keep everything else. Takeaway
Constrain the what. Let the model write the how. Check everything in between.
Review catches errors after the code is written. Rules keep them from being written. You need both, so the guide has a tool for each.
Before the code
Fill in your environment, data, model and metric. It assembles the setup prompt with all eight rules in it, ready to copy or save as a file.
OpenAfter every answer
Thirteen checks to run before you type “next”. Mark what broke and it writes the correction prompt.
Open