Neural network 2D classification - class assigment.

3 views (last 30 days)
Hi, everyone. I constructed myself simple feedforward neural network, which is suppose to classify input vector into one of four classes. I represent them as points in 2D space. i.e.
expect = [-0.5, -0.5; -0.5, 0.5; 0.5, -0.5; 0.5, 0.5];
After training session and simulation, my results are pretty good (when I look at plotted points), however I am interested in getting % number of successful classification for each point in space. It is impossible to check if output == [0.5, 0.5], becasuse life is not so simple, and values are not rounded. I am wondering, what should I add to my program to get 4 classes (one per expected point) that will show me that input vector is classified to one of them. Than what about points that will be somewhere on plot but they will no point to any desirable output?
I hope, I wrote down my problem in understandable way, and someone will be able to help me.

Answers (1)

Greg Heath
Greg Heath on 27 Mar 2012
Code your target matrix, t, with columns of the 4-dimensional unit matrix eye(4). For example:
clear all, clc
class =[randperm(4),ceil(4*rand(1,4)),randperm(4)]
class1 = 1, class2 = 2, class3 = 3, class4 = 4
ind1 = find(class==class1), N1 = numel(ind1)
ind2 = find(class==class2), N2 = numel(ind2)
ind3 = find(class==class3), N3 = numel(ind3)
ind4 = find(class==class4), N4 = numel(ind4)
t =full( ind2vec(class)) % training target matrix
[O N] = size(t)
disp(' Fabricated Neural Network Model Output')
y = softmax( t + 0.5*randn(O,N))
classy = vec2ind(y)
Pcterr = 100*sum(classy ~= class)/N
disp(' Class-Conditional Eror Rates')
t1 = t( : , ind1 )
y1 = y( : , ind1)
classy1 = vec2ind(y1)
Pcterr1 = 100*sum(classy1 ~= class1)/N1
% etc
Hope this helps.
Greg

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!