{ "cells": [ { "cell_type": "markdown", "id": "5d62c97e", "metadata": {}, "source": [ "# Results of fault diagnosis using TCN" ] }, { "cell_type": "code", "execution_count": 9, "id": "c12297e6", "metadata": {}, "outputs": [], "source": [ "from ice.fault_diagnosis.datasets import FaultDiagnosisRiethTEP\n", "from ice.fault_diagnosis.models import TCN\n", "from sklearn.preprocessing import StandardScaler\n", "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "b9cb6459", "metadata": {}, "source": [ "Download the dataset." ] }, { "cell_type": "code", "execution_count": 2, "id": "6a71a39f", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ec7af5252301494c85187fe4084fe3da", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Reading data/rieth_tep/df.csv: 0%| | 0/15330000 [00:00\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
FaultTPRFPR
000.96750.0000
110.97380.0000
230.96430.0000
340.95840.0000
450.97310.0000
560.96790.0000
670.96910.0000
790.96510.0000
8100.97880.0000
9110.95260.0000
10120.94180.0001
11130.97800.0000
12150.97520.0000
13160.96080.0000
14170.93570.0000
15180.97170.0000
16190.94820.0000
\n", "" ], "text/plain": [ " Fault TPR FPR\n", "0 0 0.9675 0.0000\n", "1 1 0.9738 0.0000\n", "2 3 0.9643 0.0000\n", "3 4 0.9584 0.0000\n", "4 5 0.9731 0.0000\n", "5 6 0.9679 0.0000\n", "6 7 0.9691 0.0000\n", "7 9 0.9651 0.0000\n", "8 10 0.9788 0.0000\n", "9 11 0.9526 0.0000\n", "10 12 0.9418 0.0001\n", "11 13 0.9780 0.0000\n", "12 15 0.9752 0.0000\n", "13 16 0.9608 0.0000\n", "14 17 0.9357 0.0000\n", "15 18 0.9717 0.0000\n", "16 19 0.9482 0.0000" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "idx = np.array([1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20]) - 1\n", "pd.DataFrame({\n", " 'Fault': idx,\n", " 'TPR': np.array(metrics['true_positive_rate'])[idx],\n", " 'FPR': np.array(metrics['false_positive_rate'])[idx],\n", "}).round(4)" ] }, { "cell_type": "code", "execution_count": 25, "id": "2ad2b5f0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Average TPR: 0.96\n" ] } ], "source": [ "print(f'Average TPR: {np.array(metrics[\"true_positive_rate\"])[idx].mean():.2f}')" ] }, { "cell_type": "code", "execution_count": 31, "id": "c3a334ba", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "96.75\n", "97.38\n", "96.43\n", "95.84\n", "97.31\n", "96.79\n", "96.91\n", "96.51\n", "97.88\n", "95.26\n", "94.18\n", "97.80\n", "97.52\n", "96.08\n", "93.57\n", "97.17\n", "94.82\n" ] } ], "source": [ "for i in np.array(metrics[\"true_positive_rate\"])[idx]*100:\n", " print(f'{i:.2f}')" ] }, { "cell_type": "code", "execution_count": null, "id": "878cf22c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }