Coder Social home page Coder Social logo

williazhang / kernel-principal-component-analysis-kpca Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iqiukp/kpca-matlab

0.0 1.0 0.0 4 MB

KPCA for dimensionality reduction, feature extraction , fault detection, and fault diagnosis

MATLAB 100.00%

kernel-principal-component-analysis-kpca's Introduction

Kernel Principal Component Analysis(KPCA)


Updated on 16 Nov 2019

  1. Used OOP to rewrite some modules.
  2. Added support for multiple kernel functions.
  3. Fixed some bugs.
  4. Accelerated the running speed of the fault diagnosis module

Notice

  1. For a brief introduction to this code, please read 'contents.m' file.
  2. Fault diagnosis module only supports gaussian kernel function at this version.
  3. The fault diagnosis module calls the precompiled file '.mexw64' to accelerate the running speed.
  4. Class is defined using 'Classdef...End', so this code can only be applied to MATLAB after the R2008a release.

Demo for dimensionality reduction (helix data)

clc
clear all
close all
addpath(genpath(pwd))

% load the training data
load('.\data\helix.mat')
traindata = helix;

% create a parameter structure for the KPCA application
application = struct('type','dimensionalityreduction',...
                     'dimensionality', 2);

% create an object for kernel function
kernel = Kernel('type', 'gauss', 'width', 24);

% create an object for kpca model
kpca = KpcaModel('application', application,...
                 'kernel', kernel);

% train KPCA model
model = kpca.train(traindata);

% get the mapping data
mappingdata = model.mappingdata;

% plot the mapping data (only support for 2D or 3D data)
plotMappingData(traindata, mappingdata);

Demo for dimensionality reduction (circle data)

clc
clear all
close all
addpath(genpath(pwd))

% load the training data
load('.\data\circledata.mat')
traindata = circledata;

% create a parameter structure for the KPCA application
application = struct('type','dimensionalityreduction',...
                     'dimensionality', 2);

% create an object for kernel function
kernel = Kernel('type', 'gauss', 'width', 6);

% create an object for kpca model
kpca = KpcaModel('application', application,...
                 'kernel', kernel);

% train KPCA model
model = kpca.train(traindata);

% get the mapping data
mappingdata = model.mappingdata;

% plot the mapping data (only support for 2D or 3D data)
plotMappingData(traindata, mappingdata, label);

Demo for dimensionality reduction (banana data)

Demo for Fault Dection (using TE process data)

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);

% 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');
*** Detection finished ***
Testing samples number:  960 
T2 alarm number      :  799 
SPE alarm number     :  859 

Demo for Fault Diagnosis (using TE process data)

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')

Demo for Dynamic KPCA (DKPCA) (using TE process data)

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,...
                     'timelag', 60);
 
% 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');
*** Detection finished ***
Testing samples number:  960 
T2 alarm number      :  768 
SPE alarm number     :  777

kernel-principal-component-analysis-kpca's People

Contributors

iqiukp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.