Spot production runs at risk of failure
A plant loses time and parts each time a machine fails in the middle of a production run. Its maintenance team can only inspect so much, so it wants to know which runs are at risk: the tool worn too far for the load, or settings that strain the machine. This guide trains a Fione model that gives each run a probability of failure, so that the team can look at the riskiest first. It goes from the download of an open dataset to a curl call of the served model, and shows why five columns of the data have to be left out.
Starting Fione from the published images and the general serving steps are in the practical guides overview. This page shows what is particular to this use case.
The business question
In the data used here, about 3% of the runs ended in a machine failure. Failures are rare, which is exactly why they are hard to catch by hand. A plant that knows which runs are most at risk can act on it:
- change the tool, or inspect the machine, before the riskiest runs;
- change the speed or load of a run that the model rates at risk;
- leave the runs that will go fine alone, instead of inspecting everything.
The model answers one question per run: will the machine fail during this run? It returns a yes/no answer (1 or 0) and, more usefully, the probability of a failure, which is what an inspection list is sorted by.
Get the data
The data is the AI4I 2020 Predictive Maintenance dataset from the UCI Machine Learning Repository:
- Page: https://archive.ics.uci.edu/dataset/601/ai4i+2020+predictive+maintenance+dataset
- Introductory paper: S. Matzka, "Explainable Artificial Intelligence for Predictive Maintenance Applications", International Conference on Artificial Intelligence for Industries, 2020 (UCI names no creator on the dataset page)
- DOI: 10.24432/C5HS5C
- Licence: Creative Commons Attribution 4.0 International (CC BY 4.0)
Attribution (UCI's citation): AI4I 2020 Predictive Maintenance Dataset [Dataset]. (2020). UCI Machine Learning Repository. https://doi.org/10.24432/C5HS5C. What we changed: we set the last 500 rows aside to try predictions on (see Prepare the CSV); no value was changed.
In an empty directory, download and unpack it:
curl -LO https://archive.ics.uci.edu/static/public/601/ai4i+2020+predictive+maintenance+dataset.zip
unzip ai4i+2020+predictive+maintenance+dataset.zipThe zip holds one file, ai4i2020.csv (522,048 bytes). If unzip says "End-of-central-directory signature not found", the download failed and the file is not a zip: delete it and run curl again.
ai4i2020.csv is a comma-separated text file of 10,001 lines (a header and 10,000 rows) with 14 columns and no empty cells. It starts with a byte order mark, invisible bytes that some programs show in front of the first column name; Fione reads the name as UDI. The data is synthetic: UCI says real predictive maintenance data is hard to obtain and publish, so this dataset was generated to reflect such data "to the best of our knowledge".
The data
| Column | What it holds |
|---|---|
UDI | 1 to 10000, in file order (UCI calls it UID, a unique identifier) |
Product ID | The product's quality variant letter followed by a serial number, such as M14860; different in every row |
Type | The quality variant: L low, M medium or H high; the same letter as at the start of Product ID |
Air temperature [K] | Air temperature, in kelvin (300 K is about 27 °C) |
Process temperature [K] | Temperature of the process, in kelvin; about 10 K above the air temperature |
Rotational speed [rpm] | Rotational speed of the tool, in revolutions per minute |
Torque [Nm] | Torque, in newton metres |
Tool wear [min] | How long the tool has been in use, in minutes |
Machine failure | The answer: 1 if the machine failed in this run, 0 if not |
TWF, HDF, PWF, OSF, RNF | Which way it failed: tool wear failure, heat dissipation failure, power failure, overstrain failure, random failure; 1 or 0 each |
UCI calls each row a data point. Product ID is different in all 10,000 rows and the data has no machine identifier, so we read a row as one run of the machine on one product, and call it "a run" below.
Machine failure is 1 for 339 of the 10,000 rows (3.4%). Two ordinary runs, and one that ended in a failure:
UDI,Product ID,Type,Air temperature [K],Process temperature [K],Rotational speed [rpm],Torque [Nm],Tool wear [min],Machine failure,TWF,HDF,PWF,OSF,RNF
1,M14860,M,298.1,308.6,1551,42.8,0,0,0,0,0,0,0
2,L47181,L,298.2,308.7,1408,46.3,3,0,0,0,0,0,0
70,L47249,L,298.9,309,1410,65.7,191,1,0,0,1,1,0The third row is a run with a high torque on a tool used for 191 minutes; it failed in two ways at once, by power (PWF) and by overstrain (OSF).
Before training, look at four things.
First, the five failure-mode columns. Whether to keep a column depends on two things: is the value known at the moment you predict, and is it computed from the outcome you are predicting? TWF, HDF, PWF, OSF and RNF say in which way the run failed. They are known only once the failure has happened, and according to UCI, Machine failure is set to 1 when at least one of them is 1: they are the answer, split into five. A model that learns from them would look almost perfect in training and could not be used before a run, when no failure has happened yet. Fione does not flag them; you uncheck them. In Read the results we show what happens when they are kept. The file does not follow UCI's rule in every row: 18 rows have RNF 1 and Machine failure 0, and 9 rows have Machine failure 1 and all five columns 0. Nothing in the data says how these 9 failed, so the model may not be able to predict them.
Second, the identifiers. UDI is the row number and Product ID is different in every row, so neither can help predict a new run. Fione unchecks both by itself, as "Looks like an ID". The quality variant they carry is in Type, which stays.
Third, how the failures were made. UCI describes the rules that generated three of the failure modes: a heat dissipation failure when the process is less than 8.6 K warmer than the air and the tool turns slower than 1,380 rpm; a power failure when torque × speed (in rad/s), the power of the process, is below 3,500 W or above 9,000 W; an overstrain failure when tool wear × torque exceeds 11,000 minNm for L (12,000 for M, 13,000 for H). We checked these rules on the file: they match every row of HDF, PWF and OSF, and no run without a failure meets any of them. Together they account for 287 of the 339 failures. The other 52 are 43 tool wear failures, which UCI says happen at a randomly chosen wear time (one of them is also marked as a random failure), and the 9 failures without a mode. So a model can learn most failures here from fixed thresholds, and its scores may be higher than on a real machine, which does not fail by fixed thresholds. UCI's description does not match the file everywhere either: it gives the variants as 50% L, 30% M and 20% H (the file has 60%, 30% and 10%), random failures as 5 rows (RNF is 1 in 19), tool wear failures as 51 (TWF is 1 in 46) at 200 to 240 minutes of wear (in the file, 198 to 253). We describe the file as it is: it is what the model learns from.
Fourth, when the values are known. UCI does not say at what point of a run the temperatures, speed, torque and tool wear are recorded, or how long before a failure. Our reading is that the speed and torque are settings of the run and the tool wear is known before it starts, so a plant can score a run before it starts with the settings it plans and the latest temperatures. If your own sensors record values during the run, score with values from before the failure, not with readings taken as it fails.
Prepare the CSV
ai4i2020.csv needs no conversion. Check it has 10,001 lines:
wc -l ai4i2020.csvThen keep some runs apart, so that you can later predict rows the model never learned from. With only 3% failures, 20 rows may well hold none (the last 20 of the file do not), so keep more: the header and the last 500 rows in new-runs.csv, and train on the other 9,500 rows in train.csv:
head -n 9501 ai4i2020.csv > train.csv
{ head -n 1 ai4i2020.csv; tail -n 500 ai4i2020.csv; } > new-runs.csvThe rows are in UDI order, and the failures are not spread evenly over them: rows 4,001 to 5,000 hold 134 of the 339 failures, 108 of them heat dissipation failures, because 676 of the 720 runs where the process is less than 8.6 K warmer than the air are there. The 500 runs set aside are cooler than average (298.8 K against 300.0 K); 13 of them (2.6%) ended in a failure, 9 of these by overstrain. They are fine for trying predictions, but they are not a fair sample of all the runs.
Keep the five failure-mode columns in both files: you will uncheck them in Fione, and the predictions page shows that the model does not use them.
Train the model
- On Projects, create a project (we named it
predictive-maintenance) and open it. - Press Upload training data, choose
train.csvand press Upload and analyze. Data analysis shows 9,500 rows, 14 columns and 0% empty cells. - Under What do you want to predict?, choose
Machine failure. Fione sees two values in it and suggests Classification. - Under Which columns should the model learn from?, Fione has unchecked
UDIandProduct ID("Looks like an ID: every value is different, so it cannot help predict."); the other 11 inputs are checked. UncheckTWF,HDF,PWF,OSFandRNF. Fione readsTypeand the five failure-mode columns as Category and the five measurements as Number. - Keep Classification under Prediction type.
- Under Maximum run time, choose 10 min (the default is 3 min; a longer run can find better models).
- Press Run.

When training ends, the page moves on to the Prediction summary.
Read the results

In our run:
- Rating: 4 out of 5. "On rows it did not learn from, the model found 81% of the “1” rows (only about 3.4% of all rows), and 97% of the rows it called “1” really were. Always guessing the most common answer would find none of them."
- Guide: "Great job! The model predicts well. Try it on new data."
- About this model: a blend of 4 models, 183 models tried, training time 6:20.
- Most useful inputs:
Torque [Nm]24%,Rotational speed [rpm]20%,Tool wear [min]19%,Air temperature [K]16%,Process temperature [K]16%.
With failures this rare, the share of right answers says little: a "model" that always says 0 is right for 96.6% of the training rows and finds no failure. So the sentence under the rating speaks of what matters here, the failures found (81%) and how often a run called a failure really failed (97%). The stars are still worked out from the share of right answers (How is the rating calculated? on the summary gives the formula and the bands): unrounded, the model's Accuracy is 0.9925, and it covers (0.9925 − 0.9657) / (1 − 0.9657) ≈ 0.78 of the distance from always guessing 0 to a perfect score, in the band of 4 stars (0.6 to 0.8).
Press Open advanced details and open the Metrics tab. It shows the figures measured on rows the models did not learn from. In our run:
- Confusion matrix: of the 326 runs that failed, the model said
1for 264 (81%) and missed 62. Of the 9,174 runs that did not fail, it said1for 9 (under 1%). Of the 273 runs it called1, 264 (97%) did fail (Precision 0.967, Recall 0.810). - AUC 0.98 (0.5 is guessing, 1 is perfect): take one run that failed and one that did not, and the model gives the one that failed the higher probability about 98% of the time.
- Top-10% lift 9.6: the 10% of runs the model rates most at risk failed 9.6 times as often as the average run. Since only 3.4% of the runs failed, 10 is the most possible: those 10% hold about 96% of all the failures.
- Average precision 0.91: "How well the true cases are ranked first; it suits rare cases. Higher is better." On the Overview tab, the Ranking metric is Average precision (classification): Fione picked it to compare the models it tried, as the answer is rare.
So a maintenance team that looks at the 10% of runs the model rates most at risk would see almost every failure, and the 1 answers alone catch four failures in five with very few false alarms. The Metrics tab does not say which runs were missed. Of the 326 failures in train.csv, 50 do not follow UCI's three fixed rules: 41 tool wear failures, which UCI says happen at a randomly chosen wear time, and the 9 failures without a mode. So at least 12 of the 62 missed failures do follow those rules: the model does not learn the rules perfectly either. These figures come from rows of the same data, set aside in turn while the models learn; because no time order is set, Fione shuffles the rows before setting them aside. Remember also that the failures here follow fixed rules (see The data); on a real machine, check the model on runs it has not learned from before relying on it.
The 1/0 answer is the more likely of the two (the model's Choosing the predicted class setting is Most likely class), so the model says 1 only when it rates a failure more likely than not. A plant does not have to use that cut-off. If a missed failure costs far more than an inspection, it can sort the runs by the probability and inspect from the top down, or inspect every run above a lower probability.
Most useful inputs is captioned "The columns that moved the predictions most, as a share of all the columns' effect." Fione works this out on its own shortly after training (about 4 seconds after it in our run), by explaining the model's predictions on rows of the training data. The torque, speed and tool wear come first, the three values in UCI's rules for power and overstrain failures, followed by the two temperatures, which are in the rule for heat dissipation failures. Until that explanation is done, the summary shows a different list instead, captioned "The columns the model relied on most, as a share of all it used." and based on the training's own measure; that list stays on the Importance tab (in our run Torque [Nm] 24%, Rotational speed [rpm] 23%, Air temperature [K] 18%, Process temperature [K] 17%, Tool wear [min] 15%, Type 3%).
To see what the five failure-mode columns do, we trained a second model in the same way with them checked. It got 5 out of 5: it found 97% of the failures, and every run it called a failure did fail (AUC 0.996, Top-10% lift 9.7). HDF, OSF, PWF and TWF came first among its most useful inputs, with 24%, 24%, 19% and 15%. Of the 326 failures it missed 9, as many as the failures without a mode in the training rows, which these columns cannot reveal. That model looks better only because it is told how the run failed, which is known once it has failed. It cannot be used to decide which runs to inspect, so its scores say nothing about how well an inspection list would work.
Make predictions
Predict the 500 runs you set aside:
- On the Prediction summary, press Make predictions.
- Choose
new-runs.csvand press Upload. Fione says that "new-runs" (500 rows) has every column the model needs, and marksUDI,Product ID,Machine failureand the five failure-mode columns as Not used by the model. KeepMachine failurechecked under Columns in the result, so that you can compare each prediction with what happened. - Press Predict. Predictions shows 500 rows × 17 columns and Download predict_new-runs.csv.
predict is the answer, and p_1 the probability of a failure. Five of the 500 rows in our run, by their place in the file (row 1 is UDI 9501):
| Row | Type | Rotational speed [rpm] | Torque [Nm] | Tool wear [min] | p_1 | predict | Machine failure (what happened) |
|---|---|---|---|---|---|---|---|
| 475 | L | 1361 | 68.2 | 172 | 0.98 | 1 | 1 (power and overstrain) |
| 114 | L | 1377 | 62.5 | 92 | 0.74 | 1 | 1 (power) |
| 167 | M | 1838 | 24.0 | 235 | 0.44 | 0 | 0 |
| 259 | L | 2271 | 16.2 | 218 | 0.13 | 0 | 1 (tool wear) |
| 77 | L | 1922 | 23.3 | 205 | 0.04 | 0 | 1 (tool wear) |
The failure modes in brackets come from the columns the model did not use. The model said 1 for 11 of the 500 runs, and all 11 failed; they are also the 11 runs with the highest p_1, and all failed by power or overstrain. The other 2 failures were tool wear failures, which UCI says happen at a randomly chosen wear time: the model gave them a p_1 of 0.13 and 0.04, 21st and 30th of the 500. Between the 11 runs called 1 and the first missed failure (12th to 20th), 7 of the 9 runs had a tool worn past 200 minutes and did not fail, such as row 167. Sorted by p_1, the 22 runs at 0.1 or more hold 12 of the 13 failures. Under the table, Why these predictions shows, for the first 5 rows, the columns that moved each prediction most; these 5 runs did not fail, and each starts from an average prediction of 2.1% and ends under 1%.
Serve it as an API
Under Serve it from your own system, press Download the serving bundle. Unpack it into a directory of its own and run the command shown on the card there, as in the overview. Use the name of your file; for our model:
unzip fione-serving-Machine-failure-model-2026-11-28-08-42-17.zip -d fione-serving-Machine-failure-model-2026-11-28-08-42-17
cd fione-serving-Machine-failure-model-2026-11-28-08-42-17
docker run --rm -p 8081:8080 -v "$PWD/model:/model:ro" ghcr.io/codelibs/fione-serving:snapshotIn another terminal, ask which columns the model expects:
curl -s localhost:8081/model{"names":["Type","Air temperature [K]","Process temperature [K]","Rotational speed [rpm]","Torque [Nm]","Tool wear [min]","Machine failure"],
"domains":[["H","L","M"],null,null,null,null,null,[0,1]],
"responseColumn":"Machine failure","category":"Binomial","nclasses":2,"nfeatures":6, ...}The names are the column names of the CSV, spaces and brackets included; use them as they are as the keys of each row. UDI, Product ID and the five failure-mode columns are not among them: the model does not use them. Send rows 475 and 167 of new-runs.csv, a run that failed and one that did not:
curl -s -X POST localhost:8081/invocations -H 'Content-Type: application/json' -d '{"instances":[{"Type":"L","Air temperature [K]":298.6,"Process temperature [K]":308.2,"Rotational speed [rpm]":1361,"Torque [Nm]":68.2,"Tool wear [min]":172},{"Type":"M","Air temperature [K]":299.1,"Process temperature [K]":310.3,"Rotational speed [rpm]":1838,"Torque [Nm]":24,"Tool wear [min]":235}]}'{"predictions":[{"label":1,"index":1,"class_probabilities":[0.015483468325412583,0.9845165316745874]},{"label":0,"index":0,"class_probabilities":[0.5575694255304442,0.44243057446955586]}]}class_probabilities follow the classes of Machine failure in domains, 0 then 1, so the second number is the probability of a failure: 0.98 and 0.44, the same as p_1 for these rows under Make predictions. A plant's system would send each planned run's values, keep its own run or machine number next to the answer, and flag the runs above the probability it chooses.
Send Type as the capital letter, as in the CSV, and the temperatures in kelvin. In our run, sending "l" instead of "L" gave no error but a different probability (0.90 instead of 0.98), and so did an air temperature in degrees Celsius (25.45 instead of 298.6 gave 0.94). Leaving out a column gave an error for that row ("missing columns"). Adding UDI, Product ID, Machine failure and the five failure-mode columns to a row, or sending the numbers as strings such as "1361", gave the same probabilities.
From an AI tool
AI tools such as Claude and Codex can do the same through Fione's MCP endpoint: upload the CSV, train, read the results and predict. Ask the tool to leave TWF, HDF, PWF, OSF and RNF out of the inputs, as above. For a few runs, the predict tool takes rows like the two above and returns predict, p_0 and p_1 for each. Called directly over MCP for the model trained above, it returned the same probabilities as the API above (0.98 and 0.44). How to connect a client and what to ask is in Run the AutoML loop from an AI tool with MCP, and the predict tool in Predicting new rows.