MATLAB Answers

how to control duplicate function names

8 views (last 30 days)
jkr on 11 Aug 2016
Commented: Greg Heath on 14 Aug 2016
I am using the Neural Network toolbox and attempting to determine how a trained patternnet would classify some test data. The documentation indicates I should use "classify" for this purpose. However, when I do so, I get an error message, because (as documented by "which classify") an unrelated function named "classify" is found preferentially on my matlabpath (/Applications/ If I "examine package contents" (I'm on a Mac), in fact that stats version of classify is the only one found. If I "doc classify" I get the stats version (re: Discriminant analysis), but at the top there is a notation: "Other uses of classify: nnet/SeriesNetwork.classify", and if I follow the offered link I find documentation on the version of classify appropriate for neural networks. How can I make that version of "classify" the one found in response to a command-line entry or a script? The same problem pertains to "predict". This overloading of function names seems like a very bad idea - what gives?


per isakson
per isakson on 11 Aug 2016
Doc says
"[Ypred,scores] = classify(net,X) estimates the classes for the data in X using the trained network, net."
In this case classify is a method of the class, SeriesNetwork, and net is an object of that class.
I guess your first input argument is not an object of SeriesNetwork.
Walter Roberson
Walter Roberson on 11 Aug 2016
patternnet and SeriesNetwork are not the same, so classify() cannot be used with a patternnet.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 11 Aug 2016


Show 2 older comments
jkr on 11 Aug 2016
The answer is supplemented by two helpful comments, one from the answer's author, another from per isakson. Walter's second answer spells out in the kind of detail I needed what I was getting wrong.
For my purposes, classifying the outputs as >= or < 0.5 (following the convention of confusion() for =) using find seems like it will do what I need.
Thanks to both per and Walter.
Walter Roberson
Walter Roberson on 11 Aug 2016
You could use round() if the values from [0, 1]
Greg Heath
Greg Heath on 14 Aug 2016
The NNET Roolbox has functions that convert vector output to classindices and vice versa.
classindices = [ 1 3 5 2 4 ]
target = full(ind2vec(classindices))
classindices = vec2ind(target)
Hope this helps.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by