Tool wear prediction project: estimate flank wear from milling sensor data in Python

One complete machine learning project on the NASA milling data set, run end to end by Skill-Lync: what flank wear is, six sensors on a machining centre, the split that decides whether the result means anything, a no-sensor baseline that beats the usual model, and the full code.

By Skill-Lync · Published 20 Nov 2026 · Every number below was produced by the code on this page (scikit-learn 1.9.1, random_state 42)

What is a tool wear prediction project?

It is a model that estimates how worn a cutting tool is from signals the machine already gives off while cutting: spindle motor current, vibration and acoustic emission. The aim is to change an insert when it is actually worn, not on a fixed timer. Think of it as judging a pencil's sharpness by the sound it makes on paper.

On the NASA milling data, a random forest on sensor features predicted flank wear to within 106 µm on average with the split most tutorials use. On a cutting setting it had never seen, the same raw features gave 154 µm, worse than a model that only knows the cutting time. Comparing each run with the same insert when it was new brought the sensors back to 87 µm. Those three numbers are the project.

87 µmmean error on unseen settings (sensors vs fresh insert)
105 µmsame test, cutting time and settings only
145cuts with a wear measurement, 16 inserts

What is in the NASA milling data set?

Recordings of 167 face-milling cuts on a Matsuura MC-510V machining centre at UC Berkeley, with six sensor channels per cut and, after many of the cuts, the flank wear of the insert measured under a microscope. A 70 mm face mill with 6 Kennametal KC710 coated carbide inserts cut cast iron and steel blocks of 483 × 178 × 51 mm.

The settings are a full 2 × 2 × 2 grid: depth of cut 1.5 or 0.75 mm, feed 0.5 or 0.25 mm per revolution, cast iron or steel, all at 826 rpm. Each of the 8 settings was run twice with a fresh set of inserts, which gives the 16 "cases". A case runs from a new insert until the wear limit, sometimes beyond: case 11 has 23 cuts, case 6 only 1.

ChannelSensorWhat it sees
smcAC, smcDCSpindle motor current (AC, and its DC part)Torque, so cutting force
vib_table, vib_spindleAccelerometers on the table and the spindleForce fluctuations, chatter
AE_table, AE_spindleAcoustic emission sensors on the table and spindleStress waves from the shear zone and the rubbing flank

Each record holds 9,000 samples per channel at 250 samples per second (36 s). The vibration and acoustic emission channels went through an RMS meter (8 ms time constant) before sampling, so they are already energy levels, not raw waveforms.

Four traps in the file. Two records are corrupt: case 2 run 1 ends in values near 1034, and case 12 run 1 is 15,360 samples of junk; drop both, so cases 2 and 12 start from run 2. Wear was not measured after every cut: 21 of the 167 records have no VB, leaving 145 usable cuts. The time field restarts for each case and the documentation gives no unit (it is usually read as minutes). And the documentation says 200 m/min equals 826 rpm, but with a 70 mm cutter 826 rpm is 182 m/min; quote the rpm.

Source: NASA "Milling Wear" data set (A. Agogino and K. Goebel, BEST Lab, UC Berkeley), file 3. Milling.zip from the NASA prognostics data repository with mill.mat and Readme.pdf (downloaded 20 Nov 2026). Machine, tool, sensor and setting details are from that Readme.

What does flank wear look like over a tool's life?

Flank wear VB is the width of the rubbed land below the cutting edge. Typically it grows fast in the first few cuts, then steadily, then quickly again near the end of the tool's life. Steel wears these inserts much faster than cast iron: the 7 steel cases with more than one cut reached 0.3 mm after 6 to 16 time units, the 8 cast iron cases after 21 to 63.

0.00.40.81.21.6020406080100VB (mm)
Cast iron (8 cases)Steel (8 cases)0.3 mm wear limitx: cutting time (the data's time field); measured points only

A worn flank rubs the workpiece instead of cutting it: forces, heat and surface roughness rise, and finally the edge chips. Tool-life tests therefore stop at a set VB; we use 0.3 mm, a common choice, but your shop's limit depends on the insert grade and the finish you need. The theory behind it, Taylor's tool life equation and the wear stages, is in the tool wear and tool life chapter of our free machining book.

Which features does the model use?

Thirteen numbers per cut, taken only while the tool is in the workpiece. For each of the six channels, a level and a spread; plus the share of the record spent cutting. The tool is "in the cut" where the DC spindle current is above the midpoint between its idle value and its 95th percentile.

The five pre-filtered channels give their mean and standard deviation. The AC current is a raw sine wave, so it gives its RMS and its 99th-percentile peak. That is deliberately simple: the point of this project is the validation, not the feature engineering.

One more trap: the current sensor clips. The DC spindle current tops out at 10.00 V. In 34 cuts it sat at that ceiling for over a quarter of the record, and 27 of those were worn past 0.3 mm; none of the cuts below 0.15 mm clipped. So the strongest wear signal stops growing exactly when the tool needs changing. On a real machine, check the sensor range before trusting the trend.

Why is a random split wrong for tool wear data?

Because cuts from the same insert are not independent. A random split puts the cut before and the cut after on the other side of the line, and the model learns that insert's personal wear curve. It must be tested on an insert it has never seen. And because every setting was run twice, the strictest honest test holds out both inserts of a setting.

Random 5-fold split of runsthe usual tutorial: same inserts in train and test106 µm
New insert, raw sensor levelsleave one insert out147 µm
New insert, clock and settings onlyno sensors at all87 µm
New setting, clock and settings onlyboth inserts of that setting held out105 µm
New setting, sensors vs the fresh insertthe honest sensor number87 µm
New setting, both combinedsensors + clock + settings83 µm
Guess the average wearthe floor any model must beat200 µm

Mean absolute error in flank wear, micrometres (1 µm = 0.001 mm); shorter is better. Every row is a random forest of 500 trees except the last.

Read the ladder top to bottom. The random split looks fine at 106 µm. On a new insert the raw sensor levels get worse (147 µm), and a model with no sensors at all, just cutting time, depth of cut, feed and material, does far better (87 µm). That is not a win for the clock. It is the twin insert: the other run of the same setting is in the training set, so the model simply reads off its wear curve.

Hold out both inserts of a setting and the clock model drops to 105 µm. The raw sensor model is no better (154 µm), because the absolute signal levels mostly tell it the depth, feed and material. Divide every feature by the same insert's first clean cut, though, and the sensors measure change rather than conditions: 87 µm. Combining both gives 83 µm. That first cut costs nothing on a real machine; you record it every time you mount fresh inserts.

Is it the seed? Five random forest seeds: new insert, raw sensors 0.148-0.151 mm; new setting, clock only 0.104-0.105 mm; new setting, relative sensors 0.086-0.088 mm. The gaps are real.

Where does each model win?

Neither wins everywhere. Held out one setting at a time, the relative-sensor model beats the clock on 4 of 8 settings, and they split by depth of cut: it wins on 4 of the 4 shallow 0.75 mm settings, the clock wins on 4 of the 4 deep 1.5 mm ones. The clock fails worst on the steel runs that wore far past the limit, where wear accelerated in a way time alone cannot predict.

Setting (held out)CasesCutsMax VBSensors vs freshClock only
Cast iron, 1.5 mm deep, 0.5 mm/rev1, 9220.81 mm55 µm45 µm
Cast iron, 1.5 mm deep, 0.25 mm/rev4, 10170.70 mm107 µm57 µm
Cast iron, 0.75 mm deep, 0.5 mm/rev2, 12240.65 mm62 µm70 µm
Cast iron, 0.75 mm deep, 0.25 mm/rev3, 11340.76 mm54 µm93 µm
Steel, 1.5 mm deep, 0.5 mm/rev5, 1690.74 mm163 µm122 µm
Steel, 1.5 mm deep, 0.25 mm/rev6, 1570.70 mm99 µm84 µm
Steel, 0.75 mm deep, 0.5 mm/rev8, 14121.14 mm102 µm155 µm
Steel, 0.75 mm deep, 0.25 mm/rev7, 13201.53 mm146 µm244 µm

Mean absolute error per held-out setting; the better model for each row is in bold. Rows are ordered cast iron then steel, deep then shallow.

What did the forest use? With the relative features, spindle acoustic emission level (29%), table acoustic emission spread (18%), AC spindle current RMS (18%) and table acoustic emission level (16%) carried most of the importance. Acoustic emission comes from the rubbing flank itself, so it is closest to what wear physically is.

Wear limit check: when would each model change the insert?
Model (unseen setting)Worn, caughtWorn, missedChanged too early
Sensors vs fresh insert63713
Clock and settings only601012

70 of 145 cuts were truly worn past 0.3 mm.

Uses the leave-one-setting-out predictions for all 145 cuts. A missed worn tool risks scrap and a broken edge; changing too early wastes insert life. Move the limit to see the trade.

The full Python code

About 60 lines of NumPy, SciPy and scikit-learn. Download the zip from the NASA repository, unzip it twice to get mill.mat, put the script next to it and run it. It prints all eight errors in about a minute on a laptop.

# Tool wear (flank wear VB) prediction on the NASA milling data set (Agogino and Goebel, UC Berkeley).
# Put mill.mat next to this script and run it: python tool_wear_walkthrough.py
import numpy as np, scipy.io as sio
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import KFold, LeaveOneGroupOut, cross_val_predict

SIG = ["smcAC", "smcDC", "vib_table", "vib_spindle", "AE_table", "AE_spindle"]
mill = sio.loadmat("mill.mat", squeeze_me=True, struct_as_record=False)["mill"]

def signals(r):
    return np.array([np.asarray(getattr(r, s), float) for s in SIG])

def clean(X):  # two records are corrupt: one has values near 1e34, one is 15,360 samples of junk
    return X.shape[1] == 9000 and np.abs(X).max() < 50

def features(X):
    dc = X[1]
    cut = dc > dc.min() + 0.5 * (np.percentile(dc, 95) - dc.min())   # samples with the tool in the workpiece
    f = []
    for k, s in enumerate(SIG):
        x = X[k][cut]
        if s == "smcAC":                                            # raw AC current: RMS and peak
            f += [x.std(), np.percentile(np.abs(x - x.mean()), 99)]
        else:                                                       # the other five are already RMS signals
            f += [x.mean(), x.std()]
    return f + [cut.mean()]                                         # share of the record spent cutting

fresh = {}                                    # sensor signature of each insert's first clean run
for r in sorted(mill, key=lambda r: r.run):
    if r.case not in fresh and clean(signals(r)):
        fresh[r.case] = np.array(features(signals(r)))

rows, VB, case, T, C = [], [], [], [], []
for r in mill:
    X = signals(r)
    if np.isnan(r.VB) or not clean(X):        # no wear measurement after this run, or a corrupt record
        continue
    rows.append(features(X)); VB.append(r.VB); case.append(r.case)
    T.append([r.time]); C.append([r.DOC, r.feed, r.material])
F, VB, case, T, C = np.array(rows), np.array(VB), np.array(case), np.array(T, float), np.array(C, float)
R = F / np.array([fresh[c] for c in case])    # each run relative to the same insert when it was new
setting = np.array([f"{d}-{f}-{m}" for d, f, m in C])  # 8 settings, each cut with two inserts
print(f"{len(VB)} runs with a wear measurement, {len(set(case))} inserts, {len(set(setting))} settings")

rf = lambda: RandomForestRegressor(n_estimators=500, min_samples_leaf=2, random_state=42, n_jobs=-1)
logo = LeaveOneGroupOut()
def mae(X, cv, groups=None):
    p = cross_val_predict(rf(), X, VB, cv=cv, groups=groups)
    return p, np.abs(p - VB).mean()

clock = np.hstack([T, C])                     # no sensors: cutting time, depth of cut, feed, material
results = {
    "random":         mae(F, KFold(5, shuffle=True, random_state=42)),
    "insert":         mae(F, logo, case),
    "insert_clock":   mae(clock, logo, case),
    "insert_rel":     mae(R, logo, case),
    "setting":        mae(F, logo, setting),
    "setting_clock":  mae(clock, logo, setting),
    "setting_rel":    mae(R, logo, setting),
    "setting_both":   mae(np.hstack([R, clock]), logo, setting),
}
for k, (p, e) in results.items():
    print(f"{k:14s} MAE {e:.3f} mm")

This is the same file we ran to produce the numbers on this page. Install with pip install numpy scipy scikit-learn (we used NumPy 2.5.5, SciPy 1.18.1, scikit-learn 1.9.1). The zip (3. Milling.zip, 15 MB) is linked from NASA's Milling Wear data page.

How do you make this project stand out?

Report the unseen-setting number and the no-sensor baseline next to it. A tool wear model that cannot beat "minutes of cutting" has not earned a place on the machine, and saying so is what makes a reviewer trust the rest of your work.

  • Fix the clipping. Drop the DC current, or replace its level with the time it spends at the 10 V ceiling, and see whether the deep-cut settings improve.
  • Use the shape of the wear curve. Wear only grows. Smooth the predictions within each insert so they never go down, then compare the error.
  • Predict the remaining life, not the wear. From each cut, how many more time units until VB reaches the limit? That is what a planner needs, and it connects to our remaining useful life project.
  • A second data set. The PHM Society 2010 data challenge has six cutters on a high-speed CNC with force sensors. Train here, test there, and write up why it fails.

The honest limits of this project

Sixteen inserts. Each setting has two tools, so the strict test has only 8 folds and one strange insert moves the headline number. Case 6 has a single cut. Report per-setting errors, as above.

Old, pre-filtered signals. The vibration and acoustic emission channels were RMS-averaged before sampling at 250 per second, so frequency features (tooth-pass harmonics, chatter) are impossible here. A modern setup would sample raw signals at tens of kilohertz.

One machine, one speed. Every cut is at 826 rpm on one machining centre with one insert grade. A different spindle, coolant or insert needs its own training data before any of these numbers carry over.

What to learn to build projects like this

Machining basics first: chip formation, cutting forces, tool wear and tool life. Then Python with NumPy and SciPy for signal handling, and classical machine learning: regression, random forests, grouped cross-validation and model evaluation. That last part is the core of Skill-Lync's Machine Learning Fundamentals In Depth course (12 weeks). Both it and Python for Mechanical Engineers (4 weeks) are ₹40,000.

FAQs

What is the NASA milling data set?

Sensor recordings from 167 cuts on a Matsuura MC-510V machining centre, made at UC Berkeley and published in NASA's prognostics data repository. Two materials (cast iron and steel), two depths of cut and two feeds give 8 settings, each run twice with a new set of inserts: 16 cases. After many cuts the flank wear VB of the insert was measured under a microscope, which is the number you predict.

Is tool wear prediction a good final-year project?

Yes. The data is free, a 15 MB download, and the whole project runs in about a minute on a laptop. It mixes manufacturing (what flank wear is and why it matters) with machine learning, and it has a real trap to explain: inserts and settings must be held out whole, or the model is tested on tools it has already seen.

Which sensor predicts tool wear best?

In our run, acoustic emission at the spindle mattered most (29% of the random forest's importance), followed by acoustic emission at the table and the AC spindle current. The DC spindle current rises clearly with wear but clips at 10 V on worn tools, so it stops carrying information exactly when you need it.

What is flank wear VB?

The width of the worn land on the flank (the face below the cutting edge) of the insert, measured in millimetres with a microscope. As the land grows, the tool rubs instead of cutting: forces, heat and surface roughness go up. Tool-life tests stop the tool at a set VB; 0.3 mm is a common choice, which we use here.

Why not just change the tool after a fixed time?

Many shops do, and on this data a model using only cutting time and the settings is hard to beat when the same setting was seen in training (mean error 87 µm). It does worse on a setting it has never seen (105 µm), and it cannot react to a bad insert or a hard spot in the casting. Sensors compared with the same insert when it was new held 87 µm on unseen settings.

Get the syllabus and fee plans

Talk to a counsellor.

Tell us your branch and year. We'll send the syllabus for the machine learning course that fits and explain the payment plans.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.