{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Predictive Maintenance\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Predictive maintenance (PdM) is a data-driven preventive maintanance program. It is a proactive maintenance strategy that uses sensors to monitor the performance and equipment conditions during operation. The PdM methods constantly analyze the data to predict when optimal maintenance schedules. It can reduce maintenance costs and prevent catastrophic equipment failure when used correctly. \n",
"\n",
"In this notebook, we will apply NeuralForecast to perform a supervised Remaining Useful Life (RUL) estimation on the classic PHM2008 aircraft degradation dataset.\n",
"\n",
"Outline
\n",
"1. Installing Packages
\n",
"2. Load PHM2008 aircraft degradation dataset
\n",
"3. Fit and Predict NeuralForecast
\n",
"4. Evaluate Predictions\n",
"\n",
"You can run these experiments using GPU with Google Colab.\n",
"\n",
""
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Installing Packages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %%capture\n",
"# !pip install git+https://github.com/Nixtla/neuralforecast.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %%capture\n",
"# !pip install git+https://github.com/Nixtla/datasetsforecast.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.rcParams['font.family'] = 'serif'\n",
"\n",
"from neuralforecast.models import NBEATSx, MLP\n",
"from neuralforecast import NeuralForecast\n",
"#from neuralforecast.losses.pytorch import DistributionLoss, HuberMQLoss, MQLoss\n",
"from neuralforecast.losses.pytorch import HuberLoss, MAE\n",
"\n",
"from datasetsforecast.phm2008 import PHM2008"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Load PHM2008 aircraft degradation dataset\n",
"\n",
"Here we will load the Prognosis and Health Management 2008 challenge dataset. This dataset used the Commercial Modular Aero-Propulsion System Simulation to recreate the degradation process of turbofan engines for different aircraft with varying wear and manufacturing starting under normal conditions. The training dataset consists of complete run-to-failure simulations, while the test dataset comprises sequences before failure."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
| \n", " | unique_id | \n", "ds | \n", "s_2 | \n", "s_3 | \n", "s_4 | \n", "s_7 | \n", "s_8 | \n", "s_9 | \n", "s_11 | \n", "s_12 | \n", "s_13 | \n", "s_14 | \n", "s_15 | \n", "s_17 | \n", "s_20 | \n", "s_21 | \n", "y | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "1 | \n", "641.82 | \n", "1589.70 | \n", "1400.60 | \n", "554.36 | \n", "2388.06 | \n", "9046.19 | \n", "47.47 | \n", "521.66 | \n", "2388.02 | \n", "8138.62 | \n", "8.4195 | \n", "392 | \n", "39.06 | \n", "23.4190 | \n", "191 | \n", "
| 1 | \n", "1 | \n", "2 | \n", "642.15 | \n", "1591.82 | \n", "1403.14 | \n", "553.75 | \n", "2388.04 | \n", "9044.07 | \n", "47.49 | \n", "522.28 | \n", "2388.07 | \n", "8131.49 | \n", "8.4318 | \n", "392 | \n", "39.00 | \n", "23.4236 | \n", "190 | \n", "
| 2 | \n", "1 | \n", "3 | \n", "642.35 | \n", "1587.99 | \n", "1404.20 | \n", "554.26 | \n", "2388.08 | \n", "9052.94 | \n", "47.27 | \n", "522.42 | \n", "2388.03 | \n", "8133.23 | \n", "8.4178 | \n", "390 | \n", "38.95 | \n", "23.3442 | \n", "189 | \n", "
| 3 | \n", "1 | \n", "4 | \n", "642.35 | \n", "1582.79 | \n", "1401.87 | \n", "554.45 | \n", "2388.11 | \n", "9049.48 | \n", "47.13 | \n", "522.86 | \n", "2388.08 | \n", "8133.83 | \n", "8.3682 | \n", "392 | \n", "38.88 | \n", "23.3739 | \n", "188 | \n", "
| 4 | \n", "1 | \n", "5 | \n", "642.37 | \n", "1582.85 | \n", "1406.22 | \n", "554.00 | \n", "2388.06 | \n", "9055.15 | \n", "47.28 | \n", "522.19 | \n", "2388.04 | \n", "8133.80 | \n", "8.4294 | \n", "393 | \n", "38.90 | \n", "23.4044 | \n", "187 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 20626 | \n", "100 | \n", "196 | \n", "643.49 | \n", "1597.98 | \n", "1428.63 | \n", "551.43 | \n", "2388.19 | \n", "9065.52 | \n", "48.07 | \n", "519.49 | \n", "2388.26 | \n", "8137.60 | \n", "8.4956 | \n", "397 | \n", "38.49 | \n", "22.9735 | \n", "4 | \n", "
| 20627 | \n", "100 | \n", "197 | \n", "643.54 | \n", "1604.50 | \n", "1433.58 | \n", "550.86 | \n", "2388.23 | \n", "9065.11 | \n", "48.04 | \n", "519.68 | \n", "2388.22 | \n", "8136.50 | \n", "8.5139 | \n", "395 | \n", "38.30 | \n", "23.1594 | \n", "3 | \n", "
| 20628 | \n", "100 | \n", "198 | \n", "643.42 | \n", "1602.46 | \n", "1428.18 | \n", "550.94 | \n", "2388.24 | \n", "9065.90 | \n", "48.09 | \n", "520.01 | \n", "2388.24 | \n", "8141.05 | \n", "8.5646 | \n", "398 | \n", "38.44 | \n", "22.9333 | \n", "2 | \n", "
| 20629 | \n", "100 | \n", "199 | \n", "643.23 | \n", "1605.26 | \n", "1426.53 | \n", "550.68 | \n", "2388.25 | \n", "9073.72 | \n", "48.39 | \n", "519.67 | \n", "2388.23 | \n", "8139.29 | \n", "8.5389 | \n", "395 | \n", "38.29 | \n", "23.0640 | \n", "1 | \n", "
| 20630 | \n", "100 | \n", "200 | \n", "643.85 | \n", "1600.38 | \n", "1432.14 | \n", "550.79 | \n", "2388.26 | \n", "9061.48 | \n", "48.20 | \n", "519.30 | \n", "2388.26 | \n", "8137.33 | \n", "8.5036 | \n", "396 | \n", "38.37 | \n", "23.0522 | \n", "0 | \n", "
20631 rows × 17 columns
\n", "