Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Amaljith Cf
Created February 10, 2021 © GPL3+

Predictive Maintenance and Anomaly Detection System

Monitoring for suboptimal production processes and future equipment faults/failure allows manufacturers to schedule maintenance effectively.

AdvancedFull instructions provided92

Things used in this project

Story

Read more

Schematics

UART Connection

Code

quickfeather-simple-stream-data-collection.bin

C/C++
quickfeather simple stream data collection firmware for capturing data from onboard mems accelerometer
No preview (download only).

qf-simple-stream-all-sensors.ssf

XML
ssf file for data capture lab
{
    "name": "QuickFeather SimpleStream",
    "uuid": "10b1db20-48a5-4442-a40e-fc530b456c89",
    "collection_methods": [
        {
            "name": "live",
            "display_name": "Live Stream Capture",
            "storage_path": null,
            "is_default": true
        }
    ],
    "device_connections": [
        {
            "name": "serial_simple_stream",
            "display_name": "Data Stream Serial Port",
            "value": 1,
            "is_default": true,
            "serial_port_configuration": {
                "com_port": null,
                "baud": 460800,
                "stop_bits": 1,
                "parity": 0,
                "handshake": 0,
                "max_live_sample_rate": 3301
            }
        },
        {
            "name": "wifi_simple",
            "display_name": "Simple Stream over WiFi",
            "value": 2,
            "is_default": true,
            "wifi_configuration": {
                "use_mqttsn": false,
                "use_external_broker": false,
                "external_broker_address":"",
                "broker_port":1885,
                "device_ip_address": null,
                "device_port": 0,
                "max_live_sample_rate": 1000000
            }
        }
    ],
    "capture_sources": [
        {
            "max_throughput": 0,
            "name": "Motion",
            "part": "MC3635",
            "sample_rates": [
                333, 250, 200, 100, 50
            ],
            "is_default": true,
            "sensors": [
                {
                    "column_count": 3,
                    "is_default": true,
                    "column_suffixes": [
                        "X",
                        "Y",
                        "Z"
                    ],
                    "type": "Accelerometer",
                    "parameters": [],
                    "sensor_id": 1229804865,
                    "can_live_stream": true
                }
            ]
        },
                {
            "max_throughput": 0,
            "name": "Audio",
            "part": "Default",
            "sample_rates": [
                16000
            ],
            "is_default": true,
            "sensors": [
                {
                    "column_count": 1,
                    "is_default": true,
                    "column_suffixes": [""],
                    "type": "Microphone",
                    "parameters": [],
                    "sensor_id": 1096107087,
                    "can_live_stream": true
                }
            ]
        },
        {
            "max_throughput": 0,
            "name": "Pressure",
            "part": "DPS310",
            "sample_rates": [
                333, 250, 200, 100, 50
            ],
            "is_default": true,
            "sensors": [
                {
                    "column_count": 1,
                    "is_default": true,
                    "column_suffixes": [
                        ""
                    ],
                    "type": "pressure",
                    "parameters": [],
                    "units": null
                }
            ],
            "sensor_id": 1334804865,
            "can_live_stream": true
        },
        {
            "max_throughput": 0,
            "name": "ADC",
            "part": "ADS1015",
            "sample_rates": [
                100,
                250,
                500,
                1000,
                1600,
                2400,
                3300
            ],
            "is_default": false,
            "sensors": [
                {
                    "column_count": 1,
                    "is_default": true,
                    "column_suffixes": [
                        ""
                    ],
                    "type": "Analog Channel"
                }
            ],
            "sensor_id": 1184532964,
            "can_live_stream": true
        },
    ],
    "is_little_endian": true
}

qf_predictive_maintenence_fan_app.bin

C/C++
prebuilt industrial predictive maintenance fan app bin file for recognition.
No preview (download only).

qf_ssi_audio_app.bin

C/C++
prebuilt binary file for audio capture.
No preview (download only).

sensiml_audio_recognition.ipynb

Python
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "sensiml_audio_recognition.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "code",
      "metadata": {
        "id": "-nH64mMtH7wO"
      },
      "source": [
        "import tensorflow as tf\n",
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import math"
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "assW5g5DH9YY"
      },
      "source": [
        "## SensiML Python Client\n",
        "\n",
        "We are going to connect to SensiML's cloud engine using the SensiML Development Python Client. If you have not yet created an account on SensiML you will need to do that before continuing. You can create a free account by going here\n",
        "\n",
        "To install the client in the colab enviornment run the command in the following cell."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ikLK27oprj8G",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "6d04ec07-d327-4cb3-9c63-1074c31f027d"
      },
      "source": [
        "!pip install sensiml-dev -U"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Requirement already up-to-date: sensiml-dev in /usr/local/lib/python3.7/dist-packages (2021.1.0)\n",
            "Requirement already satisfied, skipping upgrade: appdirs==1.4.3 in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (1.4.3)\n",
            "Requirement already satisfied, skipping upgrade: semantic-version>=2.6.0 in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (2.8.5)\n",
            "Requirement already satisfied, skipping upgrade: prompt-toolkit in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (3.0.18)\n",
            "Requirement already satisfied, skipping upgrade: requests>=2.14.2 in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (2.23.0)\n",
            "Requirement already satisfied, skipping upgrade: cookiejar==0.0.2 in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (0.0.2)\n",
            "Requirement already satisfied, skipping upgrade: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (1.3.0)\n",
            "Requirement already satisfied, skipping upgrade: seaborn in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (0.11.1)\n",
            "Requirement already satisfied, skipping upgrade: matplotlib in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (3.2.2)\n",
            "Requirement already satisfied, skipping upgrade: pyserial in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (3.5)\n",
            "Requirement already satisfied, skipping upgrade: pandas in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (0.25.3)\n",
            "Requirement already satisfied, skipping upgrade: wurlitzer in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (2.1.0)\n",
            "Requirement already satisfied, skipping upgrade: numpy in /usr/local/lib/python3.7/dist-packages (from sensiml-dev) (1.19.5)\n",
            "Requirement already satisfied, skipping upgrade: wcwidth in /usr/local/lib/python3.7/dist-packages (from prompt-toolkit->sensiml-dev) (0.2.5)\n",
            "Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->sensiml-dev) (3.0.4)\n",
            "Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->sensiml-dev) (2.10)\n",
            "Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->sensiml-dev) (1.24.3)\n",
            "Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->sensiml-dev) (2020.12.5)\n",
            "Requirement already satisfied, skipping upgrade: argparse in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->sensiml-dev) (1.4.0)\n",
            "Requirement already satisfied, skipping upgrade: pager in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->sensiml-dev) (3.3)\n",
            "Requirement already satisfied, skipping upgrade: cookiecutter in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->sensiml-dev) (1.7.2)\n",
            "Requirement already satisfied, skipping upgrade: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->sensiml-dev) (3.1.0)\n",
            "Requirement already satisfied, skipping upgrade: scipy>=1.0 in /usr/local/lib/python3.7/dist-packages (from seaborn->sensiml-dev) (1.4.1)\n",
            "Requirement already satisfied, skipping upgrade: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->sensiml-dev) (2.8.1)\n",
            "Requirement already satisfied, skipping upgrade: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->sensiml-dev) (0.10.0)\n",
            "Requirement already satisfied, skipping upgrade: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->sensiml-dev) (1.3.1)\n",
            "Requirement already satisfied, skipping upgrade: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->sensiml-dev) (2.4.7)\n",
            "Requirement already satisfied, skipping upgrade: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas->sensiml-dev) (2018.9)\n",
            "Requirement already satisfied, skipping upgrade: poyo>=0.5.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (0.5.0)\n",
            "Requirement already satisfied, skipping upgrade: python-slugify>=4.0.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (4.0.1)\n",
            "Requirement already satisfied, skipping upgrade: binaryornot>=0.4.4 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (0.4.4)\n",
            "Requirement already satisfied, skipping upgrade: MarkupSafe<2.0.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (1.1.1)\n",
            "Requirement already satisfied, skipping upgrade: six>=1.10 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (1.15.0)\n",
            "Requirement already satisfied, skipping upgrade: click>=7.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (7.1.2)\n",
            "Requirement already satisfied, skipping upgrade: Jinja2<3.0.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (2.11.3)\n",
            "Requirement already satisfied, skipping upgrade: jinja2-time>=0.2.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->sensiml-dev) (0.2.0)\n",
            "Requirement already satisfied, skipping upgrade: text-unidecode>=1.3 in /usr/local/lib/python3.7/dist-packages (from python-slugify>=4.0.0->cookiecutter->cookiejar==0.0.2->sensiml-dev) (1.3)\n",
            "Requirement already satisfied, skipping upgrade: arrow in /usr/local/lib/python3.7/dist-packages (from jinja2-time>=0.2.0->cookiecutter->cookiejar==0.0.2->sensiml-dev) (1.0.3)\n",
            "Requirement already satisfied, skipping upgrade: typing-extensions; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from arrow->jinja2-time>=0.2.0->cookiecutter->cookiejar==0.0.2->sensiml-dev) (3.7.4.3)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0UdDSPvErpO-"
      },
      "source": [
        "Next, import the SensiML python client and use it to connect to SensiML Cloud.  Run the following cell, which will ask you for your username and password. After connecting, you will be able to use the python client to manage the data in your project, create queries, build and teset models as well as download firmware. Further documentation for using the python client can be found [here](https://sensiml.com/documentation/api-methods/overview.html)."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "U9isGn3g14JP",
        "outputId": "04ccfacb-2762-4273-830a-b69fbae19195"
      },
      "source": [
        "!pip install SensiML"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Requirement already satisfied: SensiML in /usr/local/lib/python3.7/dist-packages (2020.2.1)\n",
            "Requirement already satisfied: ipython>=7.0.1; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from SensiML) (7.22.0)\n",
            "Requirement already satisfied: requests>=2.14.2 in /usr/local/lib/python3.7/dist-packages (from SensiML) (2.23.0)\n",
            "Requirement already satisfied: pyserial in /usr/local/lib/python3.7/dist-packages (from SensiML) (3.5)\n",
            "Requirement already satisfied: qgrid>=1.0.2 in /usr/local/lib/python3.7/dist-packages (from SensiML) (1.3.1)\n",
            "Requirement already satisfied: seaborn in /usr/local/lib/python3.7/dist-packages (from SensiML) (0.11.1)\n",
            "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.7/dist-packages (from SensiML) (1.3.0)\n",
            "Requirement already satisfied: semantic-version>=2.6.0 in /usr/local/lib/python3.7/dist-packages (from SensiML) (2.8.5)\n",
            "Requirement already satisfied: nrfutil<=5.0.0,>=3.3.2 in /usr/local/lib/python3.7/dist-packages (from SensiML) (5.0.0)\n",
            "Requirement already satisfied: ipywidgets>=7.5.1; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from SensiML) (7.6.3)\n",
            "Requirement already satisfied: numpy>=1.13 in /usr/local/lib/python3.7/dist-packages (from SensiML) (1.19.5)\n",
            "Requirement already satisfied: matplotlib>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from SensiML) (3.2.2)\n",
            "Requirement already satisfied: cookiejar==0.0.2 in /usr/local/lib/python3.7/dist-packages (from SensiML) (0.0.2)\n",
            "Requirement already satisfied: wurlitzer in /usr/local/lib/python3.7/dist-packages (from SensiML) (2.1.0)\n",
            "Requirement already satisfied: prompt-toolkit>=2.0.5; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from SensiML) (3.0.18)\n",
            "Requirement already satisfied: notebook==5.7.5; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from SensiML) (5.7.5)\n",
            "Requirement already satisfied: jupyter>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from SensiML) (1.0.0)\n",
            "Requirement already satisfied: jupyter-contrib-nbextensions in /usr/local/lib/python3.7/dist-packages (from SensiML) (0.5.1)\n",
            "Requirement already satisfied: jupyter-console>=6.0.0; python_version >= \"3\" in /usr/local/lib/python3.7/dist-packages (from SensiML) (6.4.0)\n",
            "Requirement already satisfied: pandas<1.0.0,>=0.20.3 in /usr/local/lib/python3.7/dist-packages (from SensiML) (0.25.3)\n",
            "Requirement already satisfied: bqplot in /usr/local/lib/python3.7/dist-packages (from SensiML) (0.12.25)\n",
            "Requirement already satisfied: appdirs==1.4.3 in /usr/local/lib/python3.7/dist-packages (from SensiML) (1.4.3)\n",
            "Requirement already satisfied: pygments in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (2.6.1)\n",
            "Requirement already satisfied: decorator in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (4.4.2)\n",
            "Requirement already satisfied: pickleshare in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (0.7.5)\n",
            "Requirement already satisfied: traitlets>=4.2 in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (5.0.5)\n",
            "Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (54.2.0)\n",
            "Requirement already satisfied: pexpect>4.3; sys_platform != \"win32\" in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (4.8.0)\n",
            "Requirement already satisfied: backcall in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (0.2.0)\n",
            "Requirement already satisfied: jedi>=0.16 in /usr/local/lib/python3.7/dist-packages (from ipython>=7.0.1; python_version >= \"3\"->SensiML) (0.18.0)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->SensiML) (2020.12.5)\n",
            "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->SensiML) (2.10)\n",
            "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->SensiML) (3.0.4)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.14.2->SensiML) (1.24.3)\n",
            "Requirement already satisfied: scipy>=1.0 in /usr/local/lib/python3.7/dist-packages (from seaborn->SensiML) (1.4.1)\n",
            "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->SensiML) (3.1.0)\n",
            "Requirement already satisfied: click>=6.0 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (7.1.2)\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (4.41.1)\n",
            "Requirement already satisfied: pyspinel==1.0.0a3 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (1.0.0a3)\n",
            "Requirement already satisfied: ecdsa>=0.13 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (0.16.1)\n",
            "Requirement already satisfied: behave in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (1.2.6)\n",
            "Requirement already satisfied: pc-ble-driver-py>=0.11.4 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (0.15.0)\n",
            "Requirement already satisfied: piccata in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (2.0.1)\n",
            "Requirement already satisfied: crcmod in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (1.7)\n",
            "Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (3.13)\n",
            "Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (1.15.0)\n",
            "Requirement already satisfied: intelhex in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (2.3.0)\n",
            "Requirement already satisfied: enum34>=1.0.4 in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (1.1.10)\n",
            "Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from nrfutil<=5.0.0,>=3.3.2->SensiML) (3.12.4)\n",
            "Requirement already satisfied: widgetsnbextension~=3.5.0 in /usr/local/lib/python3.7/dist-packages (from ipywidgets>=7.5.1; python_version >= \"3\"->SensiML) (3.5.1)\n",
            "Requirement already satisfied: jupyterlab-widgets>=1.0.0; python_version >= \"3.6\" in /usr/local/lib/python3.7/dist-packages (from ipywidgets>=7.5.1; python_version >= \"3\"->SensiML) (1.0.0)\n",
            "Requirement already satisfied: ipykernel>=4.5.1 in /usr/local/lib/python3.7/dist-packages (from ipywidgets>=7.5.1; python_version >= \"3\"->SensiML) (4.10.1)\n",
            "Requirement already satisfied: nbformat>=4.2.0 in /usr/local/lib/python3.7/dist-packages (from ipywidgets>=7.5.1; python_version >= \"3\"->SensiML) (5.1.2)\n",
            "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib>=2.0.0->SensiML) (2.4.7)\n",
            "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib>=2.0.0->SensiML) (0.10.0)\n",
            "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib>=2.0.0->SensiML) (1.3.1)\n",
            "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib>=2.0.0->SensiML) (2.8.1)\n",
            "Requirement already satisfied: cookiecutter in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->SensiML) (1.7.2)\n",
            "Requirement already satisfied: pager in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->SensiML) (3.3)\n",
            "Requirement already satisfied: argparse in /usr/local/lib/python3.7/dist-packages (from cookiejar==0.0.2->SensiML) (1.4.0)\n",
            "Requirement already satisfied: wcwidth in /usr/local/lib/python3.7/dist-packages (from prompt-toolkit>=2.0.5; python_version >= \"3\"->SensiML) (0.2.5)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (2.11.3)\n",
            "Requirement already satisfied: jupyter-client>=5.2.0 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (5.3.5)\n",
            "Requirement already satisfied: jupyter-core>=4.4.0 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (4.7.1)\n",
            "Requirement already satisfied: nbconvert in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (5.6.1)\n",
            "Requirement already satisfied: terminado>=0.8.1 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (0.9.3)\n",
            "Requirement already satisfied: prometheus-client in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (0.10.0)\n",
            "Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (0.2.0)\n",
            "Requirement already satisfied: pyzmq>=17 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (22.0.3)\n",
            "Requirement already satisfied: Send2Trash in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (1.5.0)\n",
            "Requirement already satisfied: tornado<7,>=4.1 in /usr/local/lib/python3.7/dist-packages (from notebook==5.7.5; python_version >= \"3\"->SensiML) (5.1.1)\n",
            "Requirement already satisfied: qtconsole in /usr/local/lib/python3.7/dist-packages (from jupyter>=1.0.0->SensiML) (5.0.3)\n",
            "Requirement already satisfied: lxml in /usr/local/lib/python3.7/dist-packages (from jupyter-contrib-nbextensions->SensiML) (4.2.6)\n",
            "Requirement already satisfied: jupyter-contrib-core>=0.3.3 in /usr/local/lib/python3.7/dist-packages (from jupyter-contrib-nbextensions->SensiML) (0.3.3)\n",
            "Requirement already satisfied: jupyter-nbextensions-configurator>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from jupyter-contrib-nbextensions->SensiML) (0.4.1)\n",
            "Requirement already satisfied: jupyter-highlight-selected-word>=0.1.1 in /usr/local/lib/python3.7/dist-packages (from jupyter-contrib-nbextensions->SensiML) (0.2.0)\n",
            "Requirement already satisfied: jupyter-latex-envs>=1.3.8 in /usr/local/lib/python3.7/dist-packages (from jupyter-contrib-nbextensions->SensiML) (1.4.6)\n",
            "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.7/dist-packages (from pandas<1.0.0,>=0.20.3->SensiML) (2018.9)\n",
            "Requirement already satisfied: traittypes>=0.0.6 in /usr/local/lib/python3.7/dist-packages (from bqplot->SensiML) (0.2.1)\n",
            "Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.7/dist-packages (from pexpect>4.3; sys_platform != \"win32\"->ipython>=7.0.1; python_version >= \"3\"->SensiML) (0.7.0)\n",
            "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /usr/local/lib/python3.7/dist-packages (from jedi>=0.16->ipython>=7.0.1; python_version >= \"3\"->SensiML) (0.8.2)\n",
            "Requirement already satisfied: ipaddress in /usr/local/lib/python3.7/dist-packages (from pyspinel==1.0.0a3->nrfutil<=5.0.0,>=3.3.2->SensiML) (1.0.23)\n",
            "Requirement already satisfied: parse-type>=0.4.2 in /usr/local/lib/python3.7/dist-packages (from behave->nrfutil<=5.0.0,>=3.3.2->SensiML) (0.5.2)\n",
            "Requirement already satisfied: parse>=1.8.2 in /usr/local/lib/python3.7/dist-packages (from behave->nrfutil<=5.0.0,>=3.3.2->SensiML) (1.19.0)\n",
            "Requirement already satisfied: wrapt in /usr/local/lib/python3.7/dist-packages (from pc-ble-driver-py>=0.11.4->nrfutil<=5.0.0,>=3.3.2->SensiML) (1.12.1)\n",
            "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /usr/local/lib/python3.7/dist-packages (from nbformat>=4.2.0->ipywidgets>=7.5.1; python_version >= \"3\"->SensiML) (2.6.0)\n",
            "Requirement already satisfied: jinja2-time>=0.2.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->SensiML) (0.2.0)\n",
            "Requirement already satisfied: poyo>=0.5.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->SensiML) (0.5.0)\n",
            "Requirement already satisfied: binaryornot>=0.4.4 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->SensiML) (0.4.4)\n",
            "Requirement already satisfied: MarkupSafe<2.0.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->SensiML) (1.1.1)\n",
            "Requirement already satisfied: python-slugify>=4.0.0 in /usr/local/lib/python3.7/dist-packages (from cookiecutter->cookiejar==0.0.2->SensiML) (4.0.1)\n",
            "Requirement already satisfied: defusedxml in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (0.7.1)\n",
            "Requirement already satisfied: mistune<2,>=0.8.1 in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (0.8.4)\n",
            "Requirement already satisfied: bleach in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (3.3.0)\n",
            "Requirement already satisfied: testpath in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (0.4.4)\n",
            "Requirement already satisfied: entrypoints>=0.2.2 in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (0.3)\n",
            "Requirement already satisfied: pandocfilters>=1.4.1 in /usr/local/lib/python3.7/dist-packages (from nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (1.4.3)\n",
            "Requirement already satisfied: qtpy in /usr/local/lib/python3.7/dist-packages (from qtconsole->jupyter>=1.0.0->SensiML) (1.9.0)\n",
            "Requirement already satisfied: arrow in /usr/local/lib/python3.7/dist-packages (from jinja2-time>=0.2.0->cookiecutter->cookiejar==0.0.2->SensiML) (1.0.3)\n",
            "Requirement already satisfied: text-unidecode>=1.3 in /usr/local/lib/python3.7/dist-packages (from python-slugify>=4.0.0->cookiecutter->cookiejar==0.0.2->SensiML) (1.3)\n",
            "Requirement already satisfied: webencodings in /usr/local/lib/python3.7/dist-packages (from bleach->nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (0.5.1)\n",
            "Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from bleach->nbconvert->notebook==5.7.5; python_version >= \"3\"->SensiML) (20.9)\n",
            "Requirement already satisfied: typing-extensions; python_version < \"3.8\" in /usr/local/lib/python3.7/dist-packages (from arrow->jinja2-time>=0.2.0->cookiecutter->cookiejar==0.0.2->SensiML) (3.7.4.3)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "CkM3SHoDJIFs",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 17
        },
        "outputId": "6fea66d3-4fb8-4686-ba39-7242acd1e5e9"
      },
      "source": [
        "from sensiml import *\n",
        "import sensiml.tensorflow.utils as sml_tf"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>.container { width:90% !important; }</style>"
            ],
            "text/plain": [
              "<IPython.core.display.HTML object>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "s9D22jJQr0mr"
      },
      "source": [
        "Next we are going to connect to our **SensiML Audio** Project. Run the following cell to connect to the proejct using the python client. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4SKYKeIkr6SD"
      },
      "source": [
        "dsk = SensiML()\n"
      ],
      "execution_count": 6,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "RX7WCDMNK4g4"
      },
      "source": [
        "dsk.project = \"Audio_Anomaly_Detection\""
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NbsKPtKQrucZ"
      },
      "source": [
        "### Data Exploration\n",
        "\n",
        "Lets look at the summary of the data. If you are on the free tiral, there is already created a Query for this project, othewrise you can build and create queries in the [SensiML Analytic Studio](https://app.sensiml.cloud). Queries describe the data that will go into the pipeline. Run the following cells to see the names of the queries in the project along with a visualization that summarizes for each class the number of labeled events in the project."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Kkj5iYjar-nN",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 80
        },
        "outputId": "a7806b6e-6907-4674-e727-fdcdbb2a1c26"
      },
      "source": [
        "dsk.list_queries()"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Name</th>\n",
              "      <th>Created</th>\n",
              "      <th>UUID</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Audio_Anomaly_Query</td>\n",
              "      <td>2021-04-11 08:09:43</td>\n",
              "      <td>9f7ae9ae-cc4b-4ca1-a7c6-5fa164a178d1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                  Name  ...                                  UUID\n",
              "0  Audio_Anomaly_Query  ...  9f7ae9ae-cc4b-4ca1-a7c6-5fa164a178d1\n",
              "\n",
              "[1 rows x 3 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "GzcU8vESsIMV"
      },
      "source": [
        "### Pipelines\n",
        "\n",
        "Pipelines are a key component of the SensiML workflow. Pipelines store the preprocessing, feature extraction and model building steps. When training a model, these steps are executed on the SensiML server. Once the model has been trained, the pipeline is converted to firmware code that will run on your target embedded device. For more documentation on pipelines see the advanced model building [tutorial](https://sensiml.com/documentation/advanced-model-building/advanced-model-building.html). To create a new empty pipeline, run the cell below."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qdoxoC0PQXaC"
      },
      "source": [
        "dsk.pipeline = \"Audio_Anomaly_Pipeline\""
      ],
      "execution_count": 9,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "A70YKhVIsTR7"
      },
      "source": [
        "If a pipeline with that name does not exist, a new one will be created on the server. Otherwise it will connect to a previously created pipeline.\n",
        "\n",
        "Now we are going to add our preprocessing steps to the pipeline, for a detailed description of the features available in a pipeline see the documentation [here](https://sensiml.com/documentation/pipeline-functions/overview.html). You can also list the functions by running ```dsk.list_functions(qgrid=False, functype=\"Feature Generator\")```"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iHLjlS_3IxRz"
      },
      "source": [
        "### Creating a Query"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "7UsXAlQz7OyG",
        "outputId": "18802e47-843c-4bf9-e315-4d9115f30ed1"
      },
      "source": [
        "dsk.project.columns()"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "dict_keys(['channel_0'])"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 10
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 80
        },
        "id": "rvHoVpqv7f-W",
        "outputId": "ef54eff5-1c72-4c8a-e7a2-3fa0d85ea105"
      },
      "source": [
        "dsk.list_queries()"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Name</th>\n",
              "      <th>Created</th>\n",
              "      <th>UUID</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>Audio_Anomaly_Query</td>\n",
              "      <td>2021-04-11 08:09:43</td>\n",
              "      <td>9f7ae9ae-cc4b-4ca1-a7c6-5fa164a178d1</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                  Name  ...                                  UUID\n",
              "0  Audio_Anomaly_Query  ...  9f7ae9ae-cc4b-4ca1-a7c6-5fa164a178d1\n",
              "\n",
              "[1 rows x 3 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 11
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 80
        },
        "id": "qRIOwZ5dIf4Q",
        "outputId": "4e07d737-47d5-4f75-d839-5456d7c13fd0"
      },
      "source": [
        "# Get the list of sessions/segmentation algorithms\n",
        "dsk.list_segmenters()"
      ],
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>id</th>\n",
              "      <th>parent</th>\n",
              "      <th>name</th>\n",
              "      <th>function</th>\n",
              "      <th>parameters</th>\n",
              "      <th>custom</th>\n",
              "      <th>preprocess</th>\n",
              "      <th>created_at</th>\n",
              "      <th>last_modified</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>8268</td>\n",
              "      <td>None</td>\n",
              "      <td>session_1</td>\n",
              "      <td>None</td>\n",
              "      <td>None</td>\n",
              "      <td>True</td>\n",
              "      <td>None</td>\n",
              "      <td>2021-03-12T08:24:51.378341Z</td>\n",
              "      <td>2021-03-12T08:24:51.378359Z</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "     id parent  ...                   created_at                last_modified\n",
              "0  8268   None  ...  2021-03-12T08:24:51.378341Z  2021-03-12T08:24:51.378359Z\n",
              "\n",
              "[1 rows x 9 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 12
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 342
        },
        "id": "VX53A75aIoHu",
        "outputId": "375d162b-69fc-41fc-f40d-01c5845a629f"
      },
      "source": [
        "# see the number of segments in the query\n",
        "q = dsk.get_query(\"Audio_Anomaly_Query\")\n",
        "q.statistics_segments().groupby('Label').size().plot(kind='bar')"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.axes._subplots.AxesSubplot at 0x7fa515548290>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 13
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAE0CAYAAAA10GhFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAYXElEQVR4nO3df5hddWHn8feHBAQERcoYs0AMKoiIkOA0ilDkR/GhuAqK1aJSVDTaR6rWX6DbFQRdYrfiPnX9hQ9orBR/gQuLqNCAi1QWTCANBKRYiC0pkiC/txRM+Owf54xzGWZybyZz59zvnM/ree4z95xz78yHS/LJmXO+53tkm4iIKM9WTQeIiIjJSYFHRBQqBR4RUagUeEREoVLgERGFmj2dP2yXXXbx/Pnzp/NHRkQUb8WKFffaHhq7vmuBS9oWuBp4Wv3679k+TdLXgVcCD9YvfZvtlZv6XvPnz2f58uWbmz0iotUk/Wq89b3sgT8GHG77EUlbA9dI+mG97SO2vzdVISMionddC9zVlT6P1Itb149c/RMR0bCeTmJKmiVpJbAOuML2dfWmT0taJelzkp7Wt5QREfEUPRW47Y22FwC7AYsk7Qt8DNgb+H1gZ+CU8d4rabGk5ZKWr1+/fopiR0TEZg0jtP0AcBVwlO27XXkM+BqwaIL3nGN72Pbw0NBTTqJGRMQkdS1wSUOSdqqfbwccCfxC0tx6nYBjgZv7GTQiIp6sl1Eoc4GlkmZRFf53bF8q6UpJQ4CAlcB7+pgzIiLG6GUUyipg4TjrD+9LooiI6EkupY+IKNS0XkofEf03/9QfNB2BNUte3XSEVsgeeEREoVLgERGFSoFHRBQqBR4RUagUeEREoVLgERGFSoFHRBQqBR4RUagUeEREoVLgERGFSoFHRBQqBR4RUagUeEREoVLgERGFSoFHRBQqBR4RUagUeEREoVL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bp9qzOBdsndywOTXOW2Ew5Bt4ykn4BvLeelVBUd+J+RxunUA2QdD7wk3HmC3o31QVexzeTLHqRAm8ZSc+w/dCYdXvZ/qemMjWl/m3kLGAfOmYhtP28xkJNM0nPprqR8WNUN7WA6hj404Bjbd/TVLboLodQWkLSRwFsP1TPAdLpbdOfaCB8jep+oBuAw4BvMDrFQCvYXmf7FcCZwJr6cYbtA1Pegy974C0h6QbbB4x9Pt5yW0haYfulnVMJjKxrOltELzIKpT00wfPxltviMUlbAbdLOhlYC+zQcKaInuUQSnt4gufjLbfF+4HtgfdRHfc9AThxk++IGCA5hNISkjZSjfsW1e3k/n1kE7Ct7baNf44oXgo8Wqee+3rCP/i2XzuNcSImLcfAo43+epx1I4Xe1vMBUaAUeLTRTkw8gdMpTQaL2Bw5iRltNN4ETsNUEzi9p4lAEZORPfBoo/EmcPoN8JtM4BQlyR54tFEmcIoZIQUebXSdpHeNXVlP4HR9A3kiJiXDCKN1MoFTzBQp8GgtSYcDI9PorrZ9ZZN5IjZXCjwiolA5Bh4RUagUeEREoVLgMSNJemQzXnu6pA/36/tH9EsKPCKiUCnwaA1Jr5F0naQbJf29pDkdm/eXdK2k2zvHiEv6iKSfS1ol6ZMNxI6YUAo82uQa4OW2FwLfopoTZcR+wOHAgcAnJP0nSa8C9gQWAQuAl0o6ZJozR0woc6FEm+wGfFvSXKoJrO7s2Hax7UeBRyVdRVXaBwOvAm6sX7MDVaFfPX2RIyaWAo82+Txwtu1LJB0KnN6xbbzbzAk4y/ZXpidexObJIZRok2dS3bgYnnrvy2MkbSvp96imlf058GPgHZJ2AJC0a30ZfsRAyB54zFTbS7qrY/lsqj3u70q6H7gS2KNj+yrgKmAX4Ezb/wb8m6QXAddKAngEeCuwrv/xI7rLpfQREYXKIZSIiEKlwCMiCpUCj4goVAo8IqJQKfCIiEKlwCMiCpUCj4go1P8HtA5dL4DOvH4AAAAASUVORK5CYII=\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9i5tnXO-sVf2"
      },
      "source": [
        "\n",
        "### Assembling a pipeline \n",
        "\n",
        "The pipeline for this tutorial will consist of the following steps:\n",
        "\n",
        "1.   The **Input Query** which specifies what data is being fed into the model\n",
        "2.   The **Feature Generators** which specify which features should be extracted from the raw time series data\n",
        "3.   The **Feature Transform** which specify how to transform the features after extraction. In this case it is to scale them to 1 byte each\n",
        "4.   The **Feature Selector** which selects the best features. In this case we are using the custom feature selector to downsample the data. \n",
        "\n",
        "\n",
        "The code in the following cell sets our initial variables, then specifies each step in the pipeline. For now, you don't need to dig into each of these steps, but just know that the end result will be a feaure vector scaled to 1 byte values for each of the segments that were labeled in the Data Capture Lab. We will use these features as input to our tensorflow model."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "iaolQVs-JKUc",
        "outputId": "ea566df4-737d-45b8-a8e4-47060b36ba00"
      },
      "source": [
        "dsk.project.columns()"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "dict_keys(['channel_0'])"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "vg3J1NdlSFQz"
      },
      "source": [
        "num_cols=12\n",
        "row_size=10\n",
        "\n",
        "dsk.pipeline.reset()\n",
        "dsk.pipeline.set_input_query(\"Audio_Anomaly_Query\")\n",
        "\n",
        "dsk.pipeline.add_transform(\"Windowing\", params={\"window_size\": 400,\n",
        "                                                \"delta\": 400,\n",
        "                                                \"train_delta\": 0,\n",
        "                                                \"return_segment_index\": False,\n",
        "                                                })\n",
        "\n",
        "dsk.pipeline.add_feature_generator([{'name':'MFCC', 'params':{\"columns\": [\"channel_0\"],\n",
        "                                    \"sample_rate\": 16000,\n",
        "                                    \"cepstra_count\": num_cols,\n",
        "                                    }}])\n",
        "\n",
        "dsk.pipeline.add_transform(\"Feature Cascade\", params={\"num_cascades\": row_size ,\n",
        "                                \"slide\": True,\n",
        "                                })\n",
        "\n",
        "dsk.pipeline.add_transform(\"Min Max Scale\", params={\"min_bound\": 0,\n",
        "                                \"max_bound\": 255,\n",
        "                                \"pad\": 0,\n",
        "                                \"feature_min_max_defaults\":{'minimum':-500000, 'maximum':500000.0},\n",
        "                                })"
      ],
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mxTbqlgguO_b"
      },
      "source": [
        "To see the steps currently added to your pipeline you can use the describe method"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qErWtKxUuLoJ",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "f53ce822-cdd0-4ab6-ed5f-202b01f52bae"
      },
      "source": [
        "dsk.pipeline.describe()"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "------------------------------------------------------------------------\n",
            " 0.     Name: Audio_Anomaly_Query       \t\tType: query                    \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            " 1.     Name: Windowing                 \t\tType: segmenter                \n",
            "------------------------------------------------------------------------\n",
            "\tgroup_columns: ['Class', 'Label', 'segment_uuid']\n",
            "\twindow_size: 400\n",
            "\tdelta: 400\n",
            "\ttrain_delta: 0\n",
            "\treturn_segment_index: False\n",
            "------------------------------------------------------------------------\n",
            " 2.     Name: generator_set             \t\tType: generatorset             \n",
            "------------------------------------------------------------------------\n",
            "\t 0. Name: MFCC                     \n",
            "\tgroup_columns: ['Class', 'Label', 'SegmentID', 'segment_uuid']\n",
            "------------------------------------------------------------------------\n",
            " 3.     Name: Feature Cascade           \t\tType: transform                \n",
            "------------------------------------------------------------------------\n",
            "\tgroup_columns: ['Class', 'Label', 'SegmentID', 'segment_uuid']\n",
            "\tnum_cascades: 10\n",
            "\tslide: True\n",
            "------------------------------------------------------------------------\n",
            " 4.     Name: Min Max Scale             \t\tType: transform                \n",
            "------------------------------------------------------------------------\n",
            "\tpassthrough_columns: ['CascadeID', 'Class', 'Label', 'SegmentID', 'segment_uuid']\n",
            "\tmin_bound: 0\n",
            "\tmax_bound: 255\n",
            "\tpad: 0\n",
            "\tfeature_min_max_parameters: {}\n",
            "\tfeature_min_max_defaults: {'minimum': -500000, 'maximum': 500000.0}\n",
            "------------------------------------------------------------------------\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bXLiev6csdcZ"
      },
      "source": [
        "### Executing a Pipeline\n",
        "\n",
        "At this point the pipeline has not been executed yet, we are just assemebling the steps. To run the pipeline, execute the following cell. This will print out a summary of the pipeline steps that are being run followed by the status of the pipeline execution on the server.\n",
        "\n",
        "Once the pipeline is finished running, the results will be stored in the variable *fv_t*. A summary of the execution is stored in the *s_t* variable. \n",
        "\n",
        "\n",
        "The pipeline will report status updates tell youing which step is currently running, how many batches (parallel steps) have been run and how many steps are left. This process is asyncrhonous, so if you get disconnected you can run the dsk.pipeline.get_results() to check the status of your pipeline.\n",
        "\n",
        "Another thing to note is that intermediate steps are cached. you can retrieve data from intermediate steps by using dsk.pipeline.data(<index_of_step>). If you make any changes to your pipeline, only steps after the change will need to rerun.\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "F1IBGufgKFJl",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "06d7e4ee-81d5-48bc-a6a2-aaba5965bfee"
      },
      "source": [
        "fv_s, s= dsk.pipeline.execute()"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Executing Pipeline with Steps:\n",
            "\n",
            "------------------------------------------------------------------------\n",
            " 0.     Name: Audio_Anomaly_Query       \t\tType: query                    \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            " 1.     Name: Windowing                 \t\tType: segmenter                \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            " 2.     Name: generator_set             \t\tType: generatorset             \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            " 3.     Name: Feature Cascade           \t\tType: transform                \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            " 4.     Name: Min Max Scale             \t\tType: transform                \n",
            "------------------------------------------------------------------------\n",
            "------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "\n",
            "Results Retrieved... Execution Time: 0 min. 4 sec.\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "I7-lm1z6sqDv"
      },
      "source": [
        "## SensiML Features and Tensorflow Model\n",
        "\n",
        "Now we have our features for this model, we will go ahead and train a Tensorflow Model in the colab enviornment. We will start by splitting our dataset into train, test and validate groups. The python client has a built-in function for performing this split. You can also pass in the validation data test sizes. By default, they are set to 10% each."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "s5OJ9DTVSPbz",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "2ba77b4a-e0e0-4a20-c92a-edd7e4cee1f3"
      },
      "source": [
        "\n",
        "\n",
        "x_train, x_validate, x_test, y_train, y_validate, y_test,  class_map = \\\n",
        "    dsk.pipeline.features_to_tensor(fv_s, test=.1, validate=.1)"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "-----  Summary  -----\n",
            "Class Map: {'Crowd': 0, 'Explosion': 1, 'GlassBreak': 2, 'GunShot': 3, 'Siren': 4}\n",
            "Train:\n",
            " total:  22492\n",
            " by class: [4830. 2680. 1193. 6388. 7401.]\n",
            "Validate:\n",
            " total:  2813\n",
            " by class: [612. 325. 149. 795. 932.]\n",
            "Train:\n",
            " total:  2811\n",
            " by class: [597. 337. 136. 783. 958.]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "xtp0HjuLss-B"
      },
      "source": [
        "### Feature Visualization\n",
        "Lets take a quick look at the features that we have created. Run the following cell to see the heatmap (left) along with the raw features (right).  To switch which event you are looking at change the event_index."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "MuNnS2Y_GgI-",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 282
        },
        "outputId": "f9beed0c-3473-43cf-dcfa-407dc26fcca4"
      },
      "source": [
        "import seaborn as sn\n",
        "event_index=50\n",
        "sn.heatmap(x_train[event_index].reshape(row_size,-1).T)"
      ],
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<matplotlib.axes._subplots.AxesSubplot at 0x7fa51438b290>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 19
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAD4CAYAAADSIzzWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAcDklEQVR4nO3dfZRdVZnn8e+PvAAhQIBADEk0QYI2oGLASDeKSEBedAzdy1ZwaAKi1dMdUexeo6hrhnHZuqDHkcHlNNMRwssSQUBsspBBaJqXtltA5DUhCAEEKgQCAyRChKSqnvnjnIJLTe499946L/cefx/WWXXuPueeZ9+q8NSuffbZWxGBmZmVb5uqK2Bm9ofKCdjMrCJOwGZmFXECNjOriBOwmVlFJhYdYMv6R8oZZjE8VEoYACZtW16skeHyYpWpzJ9XSSJGSoslldd2itdeKS3W5LkHabzX2PL8Y23nnEnT9xp3vPFwC9jMrCKFt4DNzErVR381OgGbWb30UfeWE7CZ1UqZffHj5QRsZvUy0j8J2DfhzKxeYqT9rQVJcyTdLOlBSaskfTEt31XSjZIeSb/ukpZL0vckrZF0v6QFWVV1AjazehkZb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GxNVlxEz/dL4ZOLqAyx8CfFzSb0m6ig6X9MMC4gCvt+KIiPXAT0m6q4owCAw2/NVwFUlCLtIxwN0R8WxB1z8CeDwinouILcDVwJ8UFIuIuCAiDoyIQ0lmUny4qFj9rtcS8K+A+ZLmpa2C44EVFddp3CSJpE9xdUR8t+BYu0ualu5vDxwJPJR3nIj4akTMjoi5JD+nf4mIQlpVknaQtOPoPvARkj91cxcRzwBPSXpHWrQIeLCIWA1OoKDuh9STwMGSpqT/FheR3IcohKQ90q9vJen//VFRsfpd1nzApYqIIUmfB35Ocld4eUSsKiKWpMuAw4DpkgaBMyPigiJikbQW/wJ4IO2bBfhaRFxXQKyZwMWSJpD8gr0iIgodIlaCGcBPk9zBRJKpUK8vMN5pwKVpI+Ax4JSiAqW/UI4E/rKoGBFxh6SrgLuBIeAein1M+CeSdgO2AEtLuonZl/wosplZRXqtC8LM7A+GE7CZWUWcgM3MKuIEbGZWESdgM7OKOAGbmVXECdjMrCL/DxTUl3uQhpGIAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "<Figure size 432x288 with 2 Axes>"
            ]
          },
          "metadata": {
            "tags": [],
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "I7PGOlc1s0Yd"
      },
      "source": [
        "### Data Augmentation\n",
        "\n",
        "It is often useful to perform data augmentation to make models more robust to unseen data. One data augmentation strategy is to apply masks in the feature space. For this tutorial, we will add masks randomly across time and sensors. To implement the masking in tensorflow we use the tf.data API. The steps in the following cell are described by:\n",
        "\n",
        "1.   Specify variables which describe the properites of our masking\n",
        "2.   Convert our training dataset that is currently a dataframe into a tf.data bject\n",
        "3.   Add a noise layer which randomly adds noise to the features.\n",
        "4.   Apply a time mask will randomly mask up to rand_max time slices.\n",
        "5.   Apply a sensor mask which will randomly mask up to rand_max sensors\n",
        "6.   Apply a shuffler which will randomize our dataset after each training iteraion.\n",
        "\n",
        "For more information about the tf.data.DataSet see the documentation [here](https://www.tensorflow.org/guide/data)"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4kNcQ9ie87zX"
      },
      "source": [
        "rand_max = 1\n",
        "min_noise=-10\n",
        "max_noise=10\n",
        "mask_value=127\n",
        "batch_size =32\n",
        "\n",
        "data  = tf.data.Dataset.from_tensor_slices((x_train, y_train))\n",
        "noise_ds = data.map(lambda image, label: sml_tf.add_image_noise(image, label, rand_max, min_noise, max_noise))\n",
        "freq_ds = noise_ds.map(lambda image, label: sml_tf.mask_image_row(image, label, rand_max, num_cols, mask_value))\n",
        "masked_ds = freq_ds.map(lambda image, label: sml_tf.mask_image_column(image, label, row_size, rand_max, num_cols, mask_value))\n",
        "\n",
        "\n",
        "# Augmented Data\n",
        "shuffle_aug = masked_ds.shuffle(buffer_size=x_train.shape[0], reshuffle_each_iteration=True).batch(batch_size)\n",
        "\n",
        "# Shuffled Data\n",
        "shuffle_ds = data.shuffle(buffer_size=x_train.shape[0], reshuffle_each_iteration=True).batch(batch_size)"
      ],
      "execution_count": 20,
      "outputs": []
    },
    {
...

This file has been truncated, please download it to see its full contents.

Knowledge Pack Audio_Anomaly

Credits

Amaljith Cf

Amaljith Cf

12 projects • 29 followers
Technology enthusiast

Comments