Industrial diagnostic of compressor connection rod defects

Neural Networks course (practical examples) © 2012 Primoz Potocnik

PROBLEM DESCRIPTION: Industrial production of compressors suffers from problems during the imprinting operation where a connection rod is connected with a compressor head. Irregular imprinting can cause damage or crack of the connection rod which results in damaged compressor. Such compressors should be eliminated from the production line but defects of this type are difficult to detect. The task is to detect crack and overload defects from the measurement of the imprinting force.

Contents

Photos of the broken connection rod

Load and plot data

close all, clear all, clc, format compact

% industrial data
load data2.mat
whos

% show data for class 1: OK
figure
plot(force','c')
grid on, hold on
plot(force(find(target==1),:)','b')
xlabel('Time')
ylabel('Force')
title(notes{1})

% show data for class 2: Overload
figure
plot(force','c')
grid on, hold on
plot(force(find(target==2),:)','r')
xlabel('Time')
ylabel('Force')
title(notes{2})

% show data for class 3: Crack
figure
plot(force','c')
grid on, hold on
plot(force(find(target==3),:)','m')
xlabel('Time')
ylabel('Force')
title(notes{3})
  Name           Size               Bytes  Class     Attributes

  force       2000x100            1600000  double              
  notes          1x3                  222  cell                
  target      2000x1                16000  double              

Prepare inputs: Data resampling

% include only every step-th data
step = 10;
force = force(:,1:step:size(force,2));
whos

% show resampled data for class 1: OK
figure
plot(force','c')
grid on, hold on
plot(force(find(target==1),:)','b')
xlabel('Time')
ylabel('Force')
title([notes{1} '  (resampled data)'])

% show resampled data for class 2: Overload
figure
plot(force','c')
grid on, hold on
plot(force(find(target==2),:)','r')
xlabel('Time')
ylabel('Force')
title([notes{2} '  (resampled data)'])

% show resampled data for class 3: Crack
figure
plot(force','c')
grid on, hold on
plot(force(find(target==3),:)','m')
xlabel('Time')
ylabel('Force')
title([notes{3} '  (resampled data)'])
  Name           Size             Bytes  Class     Attributes

  force       2000x10            160000  double              
  notes          1x3                222  cell                
  step           1x1                  8  double              
  target      2000x1              16000  double              

Define binary output coding: 0=OK, 1=Error

% binary coding 0/1
target = double(target > 1);

Create and train a multilayer perceptron

% create a neural network
net = feedforwardnet([4]);

% set early stopping parameters
net.divideParam.trainRatio = 0.70; % training set [%]
net.divideParam.valRatio   = 0.15; % validation set [%]
net.divideParam.testRatio  = 0.15; % test set [%]

% train a neural network
[net,tr,Y,E] = train(net,force',target');

Evaluate network performance

% digitize network response
threshold = 0.5;
Y = double(Y > threshold)';

% find percentage of correct classifications
correct_classifications = 100*length(find(Y==target))/length(target)
correct_classifications =
   99.7500

Application

% get sample
random_index = randi(length(force))
sample = force(random_index,:);

% plot sample
figure
plot(force','c')
grid on, hold on
plot(sample,'b')
xlabel('Time')
ylabel('Force')

% predict quality
q = net(sample');
% digitize network response
q = double(q > threshold)'

% comment network respons
if q==target(random_index)
  title(sprintf('Quality: %d  (correct network response)',q))
else
  title(sprintf('Quality: %d  (wrong network response)',q))
end
random_index =
        1881
q =
     0