Commit 4e7e25bd authored by Erik Frisk's avatar Erik Frisk

Added computation om probability of maximum fault isolation performance

parent ef28f1a2
......@@ -101,7 +101,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the 7 first residuals in all fault modes. The residuals plotted in red are supposed to alarm for the fault according to the fault sensitivity matrix."
"Plot the 7 first residuals in all fault modes. The residuals plotted in red are supposed to alarm for the fault according to the fault sensitivity matrix.\n",
"\n",
"(Fig. 4 in the paper)"
]
},
{
......@@ -153,7 +155,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the ideal fault isolability matrix corresponding to the fault sensitivity matrix."
"Plot the ideal fault isolability matrix corresponding to the fault sensitivity matrix. \n",
"\n",
"(Fig. 6 in the paper)"
]
},
{
......@@ -175,7 +179,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute consistency based diagnoses and the corresponding confusion matrix based on all 42 thresholded residuals. The confusion matrix should be compared with the ideal fault isolation matrix above."
"Compute consistency based diagnoses and the corresponding confusion matrix based on all 42 thresholded residuals. The confusion matrix should be compared with the ideal fault isolation matrix above.\n",
"\n",
"(Fig. 7 in the paper)"
]
},
{
......@@ -222,7 +228,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the confusion matrix for the random forest classifier for training data"
"Plot the confusion matrix for the random forest classifier for training data\n",
"\n",
"(Fig. 8 in the paper)"
]
},
{
......@@ -231,7 +239,8 @@
"metadata": {},
"outputs": [],
"source": [
"C = np.diag([1/sum(thdata['mode']==mi) for mi in range(nf)])@confusion_matrix(thdata['mode'], rf.predict(thdata['res']))*100\n",
"s = np.diag([1/sum(thdata['mode']==mi) for mi in range(nf)])\n",
"C = s@confusion_matrix(thdata['mode'], rf.predict(thdata['res']))*100\n",
"\n",
"plt.figure(31, clear=True, figsize=(6, 6))\n",
"du.PlotConfusionMatrix(C/100)\n",
......@@ -245,7 +254,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the variable importance, sorted, to get a ranking of predictor/residual usefullness in the classifier. Note that this classifier is not meant to be used in the diagnosis system."
"Plot the variable importance, sorted, to get a ranking of predictor/residual usefullness in the classifier. Note that this classifier is not meant to be used in the diagnosis system.\n",
"\n",
"(Fig. 10 in the paper)"
]
},
{
......@@ -268,13 +279,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute performance measures on false-alarm (FA), missed detection (MD), and an aggregated fault isolation (FI) when selecting residuals according to the ranking computed above.\n",
"Compute performance measures on false-alarm (FA), missed detection (MD), aggregated fault isolation (FI) and the probability of maximum isolability performance (FI-max)\n",
"when selecting residuals according to the ranking computed above.\n",
"\\begin{align*}\n",
" p_{\\text{FA}} &= 1 - P(NF\\in D|NF)\\\\\n",
" p_{\\text{MD}} &= \\frac{1}{n_{f}}\\sum_{f_{i}\\in \\tilde{\\mathcal{F}}} P(NF\\in D|f_{i})\\\\\n",
" p_{\\text{FI}} &= \\frac{1}{n_{f}^{2}}\\sum_{f_{i}\\in \\tilde{\\mathcal{F}}} P(NF\\notin\n",
" D|f_{i})\\sum_{f_{j}\\in \\tilde{\\mathcal{F}}}|P(f_{j}\\in D|f_{i})-I_{ij}|\n",
"\\end{align*}"
" D|f_{i})\\sum_{f_{j}\\in \\tilde{\\mathcal{F}}}|P(f_{j}\\in D|f_{i})-I_{ij}|\\\\\n",
" p_{\\text{FI-max}} &= P(D=F_{f_i}|f_i)\n",
"\\end{align*}\n",
"where $F_{f_i}$ is the set of faults nont structurally isolable from fault $f_i$."
]
},
{
......@@ -286,20 +300,32 @@
"pfa = np.zeros(nr-1)\n",
"pmd = np.zeros(nr-1)\n",
"pfi = np.zeros(nr-1)\n",
"pmfi = np.zeros((nr-1, nf))\n",
"\n",
"# Make sure isolability matrix for NF corresponds to diagnosis statement \n",
"# computed by DiagnosesAndConfusionMatrix\n",
"imk = du.IsolabilityMatrix(data['fsm'])\n",
"imk[0] = np.zeros(nf)\n",
"imk[0, 0] = 1 \n",
"\n",
"for k in range(1, nr):\n",
" imk = du.IsolabilityMatrix(data['fsm'][sortIdx[0:k]])\n",
" _, C = du.DiagnosesAndConfusionMatrix(thdata, residx=sortIdx[0:k])\n",
" dx, C = du.DiagnosesAndConfusionMatrix(thdata, residx=sortIdx[0:k])\n",
" pfa[k-1] = 1-C[0,0]\n",
" pmd[k-1] = np.mean(C[1:,0])\n",
" pfi[k-1] = np.mean(np.diag(1-C[1:, 0])@np.abs(C[1:, 1:]-im[1:, 1:]))"
" pfi[k-1] = np.mean(np.diag(1-C[1:, 0])@np.abs(C[1:, 1:]-im[1:, 1:]))\n",
" \n",
" for fi in range(nf):\n",
" pmfi[k-1, fi] = np.mean(np.all(dx[thdata['mode'] == fi] == imk[fi, :],\n",
" axis=1))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the three performance measures agains the number of selected residuals."
"Plot the three aggregated performance measures agains the number of selected residuals.\n",
"\n",
"(Fig. 11 in the paper)"
]
},
{
......@@ -326,7 +352,31 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute and display confusion matrices corresponding to selecting 10, 12, 26, and 27 residuals. The results should be compared to the confusion matrix above where all 42 residuals were used."
"Plot the probability of maximum fault isolation performance for each fault.\n",
"\n",
"(Fig. 12 in the paper)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(10, 10))\n",
"for k in range(nf):\n",
" plt.plot(pmfi[:, k], label=thdata['modes'][k])\n",
"plt.legend(loc='upper right')\n",
"BoxOff()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute and display confusion matrices corresponding to selecting 10, 12, 26, and 27 residuals. The results should be compared to the confusion matrix above where all 42 residuals were used.\n",
"\n",
"(Fig. 13 in the paper)"
]
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment