supermus
supermus

Reputation: 576

How to use trained Neural Network in Matlab for classification in a real system

I have trained Feed Forward NN using Matlab Neural Network Toolbox on a dataset containing speech features and accelerometer measurements. Targetset contains two target classes for dataset: 0 and 1. The training, validation and performance are all fine and I have generated code for this network.

Now I need to use this neural network in real-time to recognize pattern when occur and generate 0 or 1 when I test a new dataset against previously trained NN. But when I issue a command:

   c = sim(net, j)

Where "j" is a new dataset[24x11]; instead 0 or 1 i get this as an output (I assume I get percent of correct classification but there is no classification result itself):

c =

  Columns 1 through 9

    0.6274    0.6248    0.9993    0.9991    0.9994    0.9999    0.9998    0.9934    0.9996

  Columns 10 through 11

    0.9966    0.9963

So is there any command or a way that I can actually see classification results? Any help highly appreciated! Thanks

Upvotes: 4

Views: 8846

Answers (2)

sfotiadis
sfotiadis

Reputation: 977

NNs normally convert their output to a value within (0,1) using for example the logistic function. It's not a percentage or probability, just a relative measure of certainty. In any case this means is that you have to manually use a threshold (such as 0.5) to discriminate the two classes. Which threshold is best is tough to find because you must select the optimum trade off between precision and recall.

Upvotes: 2

Thomas Jungblut
Thomas Jungblut

Reputation: 20969

I'm no matlab user, but from a logical point of view, you are missing an important point:

The input to a Neural Network is a single vector, you are passing a matrix. Thus matlab thinks that you want to classify a bunch of vectors (11 in your case). So the vector that you get is the output activation for every of these 11 vectors.

The output activation is a value between 0 and 1 (I guess you are using the sigmoid), so this is perfectly normal. Your job is to get a threshold that fits your data best. You can get this threshold with cross validation on your training/test data or by just choosing one (0.5?) and see if the results are "good" and modify if needed.

Upvotes: 4

Related Questions