How to rectify error in ELM Regression model

조회 수: 3 (최근 30일)
Satyam tiwari
Satyam tiwari 2020년 6월 14일
I have been peeforming ELM regression on my dataset to determine Factor of safety for my slope. I am using following lines of code. The problem in that I am getting a result as shown in attached image. all the predicted targets are coming in one line. Is there is anyone who could suggest me any improvement.
ps. my Data is normalized in range [-1 1] for giving better learning environment to ELM.
Activation function used: tansigmoid
function [TrainingAccuracy,TestingAccuracy,TrainingTime, TestingTime,InputWeight,BiasofHiddenNeurons,OutputWeight,BiasMatrix,Y,TY,H,tempH] = ELM_regularized_NXN(TrainingData_File, TestingData_File, Elm_Type, NumberofHiddenNeurons, ActivationFunction,C)
%%%%%%%%%%% Load training dataset
train_data = TrainingData_File;
T=train_data(:,1)';
P=train_data(:,2:size(train_data,2))';
clear train_data; % Release raw training data array
%%%%%%%%%%% Load testing dataset
test_data = TestingData_File;
TV.T=test_data(:,1)';
TV.P=test_data(:,2:size(test_data,2))';
clear test_data; % Release raw testing data array
NumberofTrainingData=size(P,2); %94
NumberofTestingData=size(TV.P,2); %40
NumberofInputNeurons=size(P,1); %no of selected feature
[x,posx] = find(T==1);
W = zeros(length(T),length(T));
for i = 1:length(T)
if T(i) == 1
W(i,i)= 1/length(posx);
else
W(i,i)= 1/(length(T)-length(posx));
end
end
%save W W;
%%%%%%%%%%% Calculate weights & biases
% start_time_train=cputime;
tic;
%%%%%%%%%%% Random generate input weights InputWeight (w_i) and biases BiasofHiddenNeurons (b_i) of hidden neurons
InputWeight=rand(NumberofHiddenNeurons,NumberofInputNeurons);%*2-1;
BiasofHiddenNeurons=rand(NumberofHiddenNeurons,1);
tempH=InputWeight*P;
clear P; % Release input of training data
ind=ones(1,NumberofTrainingData);
BiasMatrix=BiasofHiddenNeurons(:,ind); % Extend the bias matrix BiasofHiddenNeurons to match the demention of H
tempH=tempH+BiasMatrix;
%%%%%%%%%%% Calculate hidden neuron output matrix H
switch lower(ActivationFunction)
case {'sig','sigmoid'}
%%%%%%%% Sigmoid
H = 1 ./ (1 + exp(-tempH));
case {'tansig'}
%%%%%%%% Tansigmoid
H=tanh(tempH);
case {'sin','sine'}
%%%%%%%% Sine
H = sin(tempH);
case {'hardlim'}
%%%%%%%% Hard Limit
H = double(hardlim(tempH));
case {'tribas'}
%%%%%%%% Triangular basis function
H = tribas(tempH);
case {'radbas'}
%%%%%%%% Radial basis function
H = radbas(tempH);
case {'renlu'}
%%%%%%%% Rectified Non-Linear Units function
H=max(0,tempH);
case {'normal'}
%%%%%%%% No function
H=tempH;
%%%%%%%% More activation functions can be added here
end
% clear tempH; % Release the temparary array for calculation of hidden neuron output matrix H
%%%%%%%%%%% Calculate output weights OutputWeight (beta_i)
OutputWeight=pinv(H') * T'; % slower implementation
n = size(T,2);
% OutputWeight=H*((W*H'*H+speye(n)/C)\(W*T'));
% n = NumberofHiddenNeurons;
% OutputWeight=((H*H'+speye(n)/C)\(H*T'));
% OutputWeight=mtimesx(H,((mtimesx(H',H)+speye(n)/C)\T'));
% OutputWeight=inv(H * H') * H * T'; % faster implementation
% end_time_train=cputime;
% TrainingTime=end_time_train-start_time_train ; % Calculate CPU time (seconds) spent for training ELM
TrainingTime=toc;
%%%%%%%%%%% Calculate the training accuracy
Y=(H' * OutputWeight)'; % Y: the actual output of the training data
% Denomalization of training result
for i=1:size(Y,1)
Y(1,i)=min(Y(1,:))+(1+Y(1,i))*(max(Y(1,:))-min(Y(1,:)))/2;
% end
end
TrainingAccuracy=sqrt(mse(T - Y)) ; % Calculate training accuracy (RMSE) for regression case
% clear H;
%%%%%%%%%%% Calculate the output of testing input
start_time_test=cputime;
tempH_test=InputWeight*TV.P;
clear TV.P; % Release input of testing data
ind=ones(1,NumberofTestingData);
BiasMatrix=BiasofHiddenNeurons(:,ind); % Extend the bias matrix BiasofHiddenNeurons to match the demention of H
tempH_test=tempH_test + BiasMatrix;
switch lower(ActivationFunction)
case {'sig','sigmoid'}
%%%%%%%% Sigmoid
H_test = 1 ./ (1 + exp(-tempH_test));
case {'tansig'}
%%%%%%%% Tansigmoid
H_test = tanh(tempH_test);
case {'sin','sine'}
%%%%%%%% Sine
H_test = sin(tempH_test);
case {'hardlim'}
%%%%%%%% Hard Limit
H_test = hardlim(tempH_test);
case {'tribas'}
%%%%%%%% Triangular basis function
H_test = tribas(tempH_test);
case {'radbas'}
%%%%%%%% Radial basis function
H_test = radbas(tempH_test);
case {'renlu'}
%%%%%%%% Rectified Non-Linear Units function
H_test=max(0,tempH_test);
case {'normal'}
%%%%%%%% No function
H_test=tempH_test;
%%%%%%%% More activation functions can be added here
end
TY=(H_test' * OutputWeight)'; % TY: the actual output of the testing data
% Denormlization of testing results
for i=1:size(TY,1)
% for j=size(Y,2)
TY(1,i)=min(TY(1,:))+(1+TY(1,i))*(max(TY(1,:))-min(TY(1,:)))/2;
% end
end
end_time_test=cputime;
TestingTime=end_time_test-start_time_test ; % Calculate CPU time (seconds) spent by ELM predicting the whole testing data
TestingAccuracy=sqrt(mse(TV.T - TY)) ; % Calculate testing accuracy (RMSE) for regression case
end
The problem i am facing is that all the predicted FOS (FOS (P)) are almost same and that is not desirable.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by