Tool-life prediction for CNC lathes

Validated and handed over Jun to Jul 2026
  • Python
  • pandas
  • scikit-learn
  • XGBoost
  • Quarto

The plants replaced cutting tools when a piece counter ran out. I rebuilt the prediction pipeline in Python to test whether the machine logs could time those replacements better. The data covered two plants: 52 million raw log rows, of which 34 million remained after cleaning.

−26%per-tool error on remaining life
Naive baseline0.257
Previous model0.0852
Final0.0634

Mean absolute error per tool on remaining life, as a fraction of the tool's preset life. Lower is better.

Method and results

  1. Validation used cycle-grouped splits over 5 and 20 seeds, a time-based split, walk-forward folds and leave-one-machine-out.
  2. At both plants the counter fell at the same rate early and late in a tool's life, and it was almost uncorrelated with spindle load (r = −0.02 and −0.07). It counts pieces against a quota. I therefore reframed the system as decision support for tool changes.
  3. XGBoost alone reduced error by about 15% against the previous model, on 5 of 5 seeds. Excluding one machine with a frozen counter accounts for the rest.
  4. Adding the raw counter as a feature drives error down to about 0.01. That accuracy comes from leakage, so the feature stays out of the model.
  5. For detecting faulty counters, a simple rule outperformed my own ML monitor (precision and recall of 1.00, against 0.60 and 0.95). I recommended the rule.
  6. The handover included a shop-floor trial plan for running tools longer, since only a controlled trial can show whether that is safe.