I used this MATLAB script using Neural Network toolbox. The important features were selected based on a threshold.
clear all;
P = load('train1.txt');
T = load('trainout1.txt');
Ps = load('test1.txt');
Ts = load('testout1.txt');
Net = newff(minmax(P), [300, 200, 150, 1], {'logsig', 'logsig', 'logsig', 'logsig'}, 'trainscg' );
Net.trainParam.epochs = 1000;
Net.trainParam.goal = 0.0001;
[Net_t, TR] = train(Net,P,T);
y = sim(Net_t,Ps);
% figure
x=[1:37]; % to draw the x axis values
efficiency = 1 - (sum(abs(round(y)-Ts)))/37;
efficiency
% plot(x, y, 'bo--', x, Ts, 'r*-');
% legend('network','actual');
% Selection of Features
Threshold = 0.90;
for i=1:300
disp 'Current Iteration'
disp(i)
FP = P;
FPs = Ps;
FP(i,:) = [];
FPs(i,:) = [];
Net = newff(minmax(FP), [299, 200, 150, 1], {'logsig', 'logsig', 'logsig', 'logsig'}, 'trainscg' );
Net.trainParam.epochs = 1000;
Net.trainParam.goal = 0.0001;
[Net_t, TR] = train(Net,FP,T);
y = sim(Net_t,FPs);
efficiency = 1 - (sum(abs(round(y)-Ts)))/37;
disp(efficiency);
if (efficiency < Threshold)
disp(i)
disp(' is an Important Feature');
end
end
No comments:
Post a Comment