sxsphinxstack

Skills / Working / Train a model

Working Code skill

Train a model

Train their first machine learning model honestly.

Walk someone through their first honest machine learning project: a small model, data they are allowed to use, an evaluation that compares against a dumb baseline, and a demo. The lasting lesson is epistemic. Knowing what a model's number means and refusing to oversell it.

Ground rules

  • Data must be theirs or clearly licensed: something they collected (their study hours, their game results, photos they took) or an open dataset with a license they read (UCI, Kaggle open datasets, government open data). No scraping people's content, nothing with personal information about others. Small is fine; a few hundred rows teaches everything.
  • Free and local: Python with scikit-learn, or a free Colab notebook if their machine struggles. No paid APIs, no GPU rental. Fine- tuning giant models is out of scope; a classifier or regressor they can inspect is the right first model.
  • The baseline is non-negotiable. Before any model trains, compute the dumbest predictor: most common class, or the mean. Every later number is reported next to it. A model that beats 90% baseline accuracy with 91% gets described exactly that way.
  • Split before you touch. Create train, validation, and test sets. The test set goes in a drawer and is used once, after model choices are finished. Explain leakage with one concrete example from their own dataset, and check for it together.
  • Honest words only, in the README and out loud: "on my 300 examples it was right 84% of the time; always guessing the majority gets 76%". Never "the AI knows", never an accuracy claim without the baseline and the dataset size beside it.

The path

  1. Pick the question and the data: what is being predicted, from what features, and why they are allowed to use this data. Load it and look at twenty raw rows together before anything else.
  2. Baseline first: majority class or mean, scored on the validation split made at the start. Write the number down.
  3. Train a simple model (logistic regression or a small tree or forest). Score on the validation split. Compare with the baseline in one sentence they say out loud.
  4. Look at validation mistakes, one at a time. Which examples fool it, and is there a reason? One round of improvement (a better feature, more data, a different model), then re-evaluate the same way. Stop after one round; the loop matters more than the score. Freeze the chosen method, then evaluate the baseline and model on the untouched test set once. Do not choose another model after seeing that result.
  5. Demo: a small page or notebook where a new input gets a prediction. If the model exports to JSON or ONNX easily, a static page works; otherwise the demo is the notebook, shipped in the repo with outputs visible.
  6. README in their words: the question, the data and its origin, the baseline, the result, and a limitations paragraph saying where it would fail (new school, next season, different camera).