forked from iqiukp/KPCA-MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemoFaultDiagnosis.m
86 lines (64 loc) · 2.87 KB
/
demoFaultDiagnosis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%{
Examples for fault diagnosis based on KPCA
Notice:
(1) You can use different kernel functions by creating different
kernel objects.
(2) Dynamic KPCA is spoported in this code. Just add a field named
'timelag'. Shown as below:
application = struct('type','faultdetection',...
'cumulativepercentage', 0.75,...
'significancelevel', 0.95,...
'timelag', 10);
(3) The module of fault diagnosis is closed by default. If you
want to use this module, just add somes fields in the parameter
structure for the kpca application. For example:
Defalut:
application = struct('type','faultdetection',...
'cumulativepercentage', 0.75,...
'significancelevel', 0.95);
Add fault diagnosis module:
application = struct('type','faultdetection',...
'cumulativepercentage', 0.75,...
'significancelevel', 0.95,...
'faultdiagnosis','on',...
'diagnosisparameter', 0.7);
(4) The fault diagnosis module is only supported for gaussian
kernel function. Although this release has accelerated the
speed of fault diagnosis, it may still take a long time when
the number of the training data is large.
%}
clc
clear all
close all
addpath(genpath(pwd))
% load the original process data of the TE process
load('.\data\teprocess.mat')
% normalization (in general, this step is important for fault detection)
[traindata, testdata] = normalize(traindata, testdata);
% create a parameter structure for the KPCA application
application = struct('type','faultdetection',...
'cumulativepercentage', 0.75,...
'significancelevel', 0.95,...
'faultdiagnosis','on',...
'diagnosisparameter', 0.7);
% create an object for kernel function
kernel = Kernel('type', 'gauss', 'width', 800);
% create an object for kpca model
kpca = KpcaModel('application', application,...
'kernel', kernel);
% train kpca model
model = kpca.train(traindata);
% test KPCA model
testresult = kpca.test(model, testdata);
% visualize the testing results
plotTestResult(model.spelimit, testresult.spe, 'SPE');
plotTestResult(model.t2limit, testresult.t2, 'T2');
% create a parameter structure for the fault diagnosis
contribution = diagnoseFault(testresult, ...
'startingtime', 301,...
'endingtime', 500,...
'theta', 0.7);
%
% % visualize the results of fault diagnosis
plotContribution(contribution, 'SPE')
plotContribution(contribution, 'T2')