{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Predictive Maintenance with IoT Sensor Data\n",
        "Xenors practice notebook. Run each cell and compare the output with the tutorial page.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Create rolling sensor features\n",
        "Rolling features capture trend but must use only past data at prediction time.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "s=pd.Series([40,42,41,50,55])\n",
        "print(pd.DataFrame({'temp':s,'roll3':s.rolling(3).mean()}))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Expected/checkpoint**\n",
        "```text\ntemp roll3\n40 NaN\n42 NaN\n41 41.0\n50 44.3\n55 48.7\n```\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Translate probabilities into maintenance priorities\n",
        "Ranking risk can be more useful operationally than a hard binary prediction.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "assets=[('A',.12),('B',.81),('C',.46)]\n",
        "print(sorted(assets,key=lambda x:x[1],reverse=True))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "**Expected/checkpoint**\n",
        "```text\n[('B', 0.81), ('C', 0.46), ('A', 0.12)]\n```\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.x"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}