Predictive maintenance project: predict jet-engine remaining life with Python

One complete machine learning project on NASA's turbofan engine data, run end to end by Skill-Lync: what the sensors show, how to set the target, the validation mistake most tutorials make, real test results and the full code.

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

What is a predictive maintenance project?

It is a model that reads a machine's sensor history and estimates how long it can keep running before it fails, its remaining useful life (RUL). Maintenance is then planned just before failure instead of on a fixed calendar. Think of it as a fuel gauge for wear: the model's job is to say how much is left.

On NASA's C-MAPSS FD001 data, a random forest on 30-cycle sensor features predicted the remaining life of 100 unseen engines with an RMSE of 17.9 cycles. 80 of the 100 predictions landed within ±20 cycles of the truth. Below is how we got there, step by step, including what didn't work.

17.9cycles RMSE on 100 test engines
80/100within ±20 cycles
10.0 → 17.1CV error once the leak is closed

What is in the NASA C-MAPSS dataset?

C-MAPSS is NASA's simulated run-to-failure data for a large turbofan engine. The FD001 subset has 100 training engines, each recorded every flight cycle from healthy until it fails, and 100 test engines cut off some time before failure. For each test engine you predict the cycles left; NASA gives the true answers to check against.

FD001 is the easiest of the four subsets: one operating condition (sea level) and one fault mode, degradation of the high-pressure compressor (HPC). The training file has 20,631 rows. Training engines lasted between 128 and 362 cycles (median 199). Test engines stop after 31 to 303 cycles, with 7 to 145 cycles truly left.

Each row holds the engine number, the cycle, three operating settings and 21 sensors. In FD001, 7 of the 21 sensors never change (or flip between two values), so they carry no information. These are the 14 we kept:

ColumnSymbolWhat it measuresUnit
s2T24Total temperature at LPC outlet°R
s3T30Total temperature at HPC outlet°R
s4T50Total temperature at LPT outlet°R
s7P30Total pressure at HPC outletpsia
s8NfPhysical fan speedrpm
s9NcPhysical core speedrpm
s11Ps30Static pressure at HPC outletpsia
s12phiFuel flow to Ps30 ratiopps/psi
s13NRfCorrected fan speedrpm
s14NRcCorrected core speedrpm
s15BPRBypass ratio-
s17htBleedBleed enthalpy-
s20W31HPT coolant bleedlbm/s
s21W32LPT coolant bleedlbm/s

Names and units from the C-MAPSS paper: Saxena, Goebel, Simon and Eklund, "Damage Propagation Modeling for Aircraft Engine Run-to-Failure Simulation", PHM08. LPC/HPC = low/high-pressure compressor, LPT/HPT = low/high-pressure turbine. Download: NASA PCoE data repository, item 6 (Turbofan Engine Degradation Simulation).

What does engine wear look like in the sensor data?

Flat for most of the engine's life, then a steady climb in the last 100 or so cycles. The chart lines up all 100 training engines at their failure point. Static pressure at the compressor outlet (Ps30) barely moves early on, then rises sharply as the compressor degrades. That shape decides how to set up the target.

47.247.447.647.848.048.2050100150200last 125 cyclesPs30 (psia), 10-cycle meanCycles before failure → failure
Median of 100 engines10th-90th percentile

In numbers: the median Ps30 is 47.273 psia 230 cycles before failure, 47.403 psia at 125 cycles before failure, and 48.099 psia at failure. Most of the change happens in the shaded zone. Other sensors tell the same story: T50 rises, while phi and the two coolant bleed flows fall. That is why a model that combines them beats any single sensor.

How do you set the target for remaining useful life?

Count the cycles left until failure for every row, then cap that count at 125. The cap matters because a healthy engine looks the same at 300 cycles left as at 200, so asking a model to tell them apart only teaches it noise. With the cap, it predicts "healthy" early and starts counting down when wear shows.

Here Tfail is the engine's last recorded cycle. This is called a piecewise-linear target. 125 is a common choice in published work; try values between 110 and 140 and watch the test error. In our run, the identical forest trained on the uncapped count scored 24.1 cycles RMSE against 17.9 with the cap.

Which features work for remaining life prediction?

Smoothed sensor levels and their trends. One cycle's reading is noisy, so for each sensor we take the mean of the last 30 cycles (where it is now) and the mean change per cycle over the same window (how fast it is moving). Fourteen sensors give 28 features, plus the cycle count.

The forest's most important features, from its own importance scores: T30 30-cycle mean (60%), cycle count (15%), T24 30-cycle mean (4%), Nc 30-cycle mean (3%), htBleed 30-cycle mean (2%), BPR 30-cycle mean (2%). Smoothed levels dominate; trends add less than you might expect on FD001 because the noise is large compared with the drift per cycle. The sensors are strongly correlated, so the forest leans on one of them (T30) and the others share what is left; that doesn't make them useless. The cycle count helps because older engines have less life left on average.

Compare that with the simplest model, a linear regression on the current raw readings: 21.9 cycles RMSE. Smoothing and a non-linear model are worth about 4.0 cycles here.

Why is a random train/test split wrong for this data?

Because neighbouring rows come from the same engine and look almost identical. Split rows at random and the model is tested on engines it has already seen, cycle by cycle. In our run that made the cross-validation error look like 10.0 cycles. Holding out whole engines gave the honest figure: 17.1.

The test set agreed with the honest number: 17.9 cycles. The random split made the error look 42% smaller than it really is. In scikit-learn the fix is one line: GroupKFold with the engine number as the group. The same mistake shows up in bearing, tool-wear and battery projects whenever several rows come from one physical unit. Interviewers who know ML look for it.

How accurate is the model on the test engines?

The random forest predicted the 100 test engines with an RMSE of 17.9 cycles. For comparison, guessing the same number for every engine scores 43.1, and published deep-learning models from 2016-2018 report 12.6 to 18.5 on the same subset. So a classical model gets most of the way; the last few cycles cost a lot more effort.

Two metrics are standard on C-MAPSS. RMSE treats early and late errors alike. The PHM08 challenge score punishes late predictions harder, because predicting failure too late means the engine fails in service:

A prediction 20 cycles too late () adds 6.39 to the score; 20 cycles too early () adds 3.66. Lower is better for both.

ModelTest RMSE (cycles)PHM08 score
Same guess for every engine43.133,629
Linear regression, current readings21.91,314
Random forest, uncapped target24.13,710
Random forest, 30-cycle features, capped target17.9533

All four trained on the 100 training engines and scored on NASA's true RUL for the 100 test engines (uncapped). Published FD001 test RMSEs, as compiled in this open-access comparison (Table 5): CNN, Li et al. 2018: 12.61; LSTM, Zheng et al. 2017: 16.14; CNN, Babu et al. 2016: 18.45. Their targets and preprocessing differ slightly from ours.

0040408080120120160160cap 125Predicted RUL (cycles)True RUL (cycles)
Test engineMore than 20 cycles lateWithin ±20 cyclesPerfect prediction

Read the chart from right to left. Engines with lots of life left sit on a flat line near the cap: the model correctly says "healthy" but can't say by how much. For the 33 engines with more than 100 cycles left, the RMSE is 24.2 cycles. Close to failure (left side) the predictions hug the diagonal: for the 33 engines with 50 or fewer cycles left it is 9.7, and that is where it matters for maintenance. 52 of 100 predictions were late, 5 by more than 20 cycles; the worst was 35.7 cycles late and the worst early miss 62.8 cycles.

When should the engine be pulled for maintenance?

That is a business decision on top of the model. Pick an alert level: any engine predicted to have fewer cycles left than that gets inspected. Set it low and you miss engines that are about to fail; set it high and you pull healthy engines early. Move the slider to see the trade-off on the 100 test engines.

-engines that truly had ≤ 30 cycles left and were caught
-of those missed (fail before inspection)
-healthy engines pulled early (> 30 left)

An engine "needs maintenance" here if it truly had 30 cycles or fewer left. The right level comes from the cost of an unplanned failure against the cost of an early shop visit. A missed failure usually costs far more, so set the alert above the danger line: on this data, 50 cycles catches 25 of 25 near-failure engines at the cost of 5 early pulls, while 30 cycles misses 8.

The full Python code

Forty-odd lines of pandas and scikit-learn. Put the three FD001 text files next to the script and run it. It prints both cross-validation errors, the test RMSE (17.9) and the PHM08 score (533). It takes about two minutes on a laptop, most of that in the two cross-validation runs.

# Predict remaining useful life (RUL) of turbofan engines: NASA C-MAPSS FD001.
# pip install numpy pandas scikit-learn ; put train_FD001.txt, test_FD001.txt, RUL_FD001.txt next to this file.
import numpy as np, pandas as pd
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GroupKFold, KFold, cross_val_predict

cols = ["unit", "cycle", "os1", "os2", "os3"] + [f"s{i}" for i in range(1, 22)]
read = lambda f: pd.read_csv(f, sep=r"\s+", header=None, names=cols)
train, test = read("train_FD001.txt"), read("test_FD001.txt")
true_rul = np.loadtxt("RUL_FD001.txt")

# 1. Target: cycles left before failure, capped at 125 (a healthy engine shows no trend to learn from)
CAP = 125
train["rul"] = train.groupby("unit").cycle.transform("max") - train.cycle
train["y"] = train.rul.clip(upper=CAP)

# 2. Features: 14 sensors that change (7 are constant in FD001), smoothed over the last 30 cycles + their trend
SENSORS = ["s2", "s3", "s4", "s7", "s8", "s9", "s11", "s12", "s13", "s14", "s15", "s17", "s20", "s21"]
W = 30
def features(df):
    g = df.groupby("unit")[SENSORS]
    mean = g.transform(lambda s: s.rolling(W, min_periods=1).mean()).add_suffix("_mean")
    slope = g.transform(lambda s: s.diff().rolling(W, min_periods=1).mean()).fillna(0).add_suffix("_slope")
    return pd.concat([mean, slope, df[["cycle"]]], axis=1)
X, y, groups = features(train), train.y, train.unit

# 3. Validate the honest way: whole engines held out (GroupKFold), not random rows
rf = RandomForestRegressor(n_estimators=200, min_samples_leaf=5, n_jobs=-1, random_state=42)
rmse = lambda a, b: float(np.sqrt(np.mean((np.asarray(a) - np.asarray(b)) ** 2)))
leaky = rmse(y, cross_val_predict(rf, X, y, cv=KFold(5, shuffle=True, random_state=42)))
honest = rmse(y, cross_val_predict(rf, X, y, cv=GroupKFold(5), groups=groups))
print(f"CV RMSE, random rows (leaks): {leaky:.1f}   whole engines held out: {honest:.1f}")

# 4. Train on all 100 engines, predict at the last recorded cycle of each test engine
rf.fit(X, y)
last = features(test).groupby(test.unit).tail(1)
pred = rf.predict(last)
d = pred - true_rul                                     # d > 0: predicted too late (engine fails first)
score = float(np.sum(np.where(d < 0, np.exp(-d / 13) - 1, np.exp(d / 10) - 1)))
print(f"Test RMSE: {rmse(pred, true_rul):.1f} cycles   PHM08 score: {score:.0f}")

This is the same file we ran to produce the numbers on this page. Install with pip install numpy pandas scikit-learn (we used scikit-learn 1.9).

How do you make this project stand out?

Do one thing the tutorials don't. Move to FD002 or FD004, where six operating conditions hide the wear unless you normalise each condition separately. Add prediction intervals so the model says how sure it is. Or explain each prediction in physical terms: which module is degrading and why the sensors moved.

  • Multi-condition data. FD002 and FD004 mix six flight conditions. Cluster the three operating settings, standardise each sensor within its cluster, then rebuild the same features. Your FD001 code becomes a baseline.
  • Uncertainty. A maintenance planner needs a range, not just a number. Quantile regression forests or the spread of the forest's trees give a first prediction interval.
  • A sequence model. Feed the raw 30-cycle windows to a 1D CNN or an LSTM and compare against the forest above, using the same GroupKFold split. Report both, honestly.
  • A second machine. Repeat the pipeline on the Case Western bearing vibration data, listed with other free datasets on our AI for mechanical engineers hub.

The honest limits of this project

It is simulated data. C-MAPSS engines run from healthy to failure with no repairs, every sensor working and the true answer known. Real fleet data has gaps, maintenance actions mid-life and very few recorded failures. A model that scores well here proves you know the pipeline, not that it would fly.

The test score is a single run. With 100 test engines, a few odd engines move the RMSE by a cycle or more. Change random_state or the window and you will see results shift by about that much; report the spread, not one lucky number.

The cap is a choice you make, not a fact. It also limits how far ahead the model can see: no prediction will exceed 125 cycles, so the model can't plan maintenance beyond that horizon.

What to learn to build projects like this

Python and pandas for the data handling, then classical machine learning: regression, random forests, cross-validation and model evaluation. That is the core of Skill-Lync's Machine Learning Fundamentals In Depth course (12 weeks). If you are new to coding, start with Python for Mechanical Engineers (4 weeks). Both are ₹40,000.

FAQs

Is NASA C-MAPSS a good final-year project for mechanical engineers?

Yes, if you go beyond the tutorial. The data is free, small (20,631 training rows) and needs no special hardware. What makes it a strong project is honest validation, a clear maintenance decision (when to pull the engine) and one extension, such as the multi-condition FD002 subset or prediction intervals.

What is a good RMSE on C-MAPSS FD001?

Our random forest scored 17.9 cycles on the 100 test engines. Published deep-learning results include 12.61 (a 2018 CNN) and 16.14 (a 2017 LSTM). Below 20 is a reasonable classical-ML result. If a simple model beats the published deep models by a wide margin, check for leakage before celebrating.

Why cap remaining useful life at 125 cycles?

A healthy engine shows no trend in its sensors, so the model can't tell 300 cycles left from 200. Capping the target at 125 tells it to predict "healthy" early in life and count down only once wear appears. Without the cap, the same forest scored 24.1 cycles instead of 17.9.

Do I need deep learning for predictive maintenance?

No. A random forest on well-chosen features gets you most of the way and is easier to explain to a maintenance team. Deep models (CNN, LSTM) help when you have many operating conditions and long raw signals. Learn the classical pipeline first; it is the same pipeline the deep models plug into.

Is this data from real jet engines?

No. C-MAPSS is a NASA simulation of a large turbofan engine with wear injected into its modules and sensor noise added. It is the standard benchmark because every engine runs to failure and the true answers are known. Real fleet data is messier: missing sensors, maintenance actions mid-life and far fewer failures.

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.