# Extracting information from Classify

I have used Mathematica's automated Classify function:

class = Classify[trainlist, Method -> "NeuralNetwork",
PerformanceGoal -> "Quality"];

acc = ClassifierMeasurements[class, testlist];


'trainlist' has 720 examples and 'testlist' has 180 examples. I get 89% accuracy. Great. But now I would like build the network from scratch so I can understand it better. That turns out to be very difficult since Classify[] is like a black box.

The most information I can get about how the network is built is from these two tables. So I tried to build my own from this information:

net = NetChain[{LinearLayer[50, "Input" -> 251],
ElementwiseLayer["SELU"], LinearLayer[50, "Input" -> 50],
ElementwiseLayer["SELU"], LinearLayer[9, "Input" -> 50],
SoftmaxLayer["Input" -> {9}]}]

netin = NetInitialize[net]

nettrain =
NetTrain[netin, trainlist[[1 ;; 576]], Method -> "ADAM",
MaxTrainingRounds -> 1000, ValidationSet -> trainlist[[577 ;; 720]]]


In all there are about 15500 parameters (I assume they mean weights). But when I check the accuracy, it's only 0.1111. I have nine classifications so that means it only does as well as random guessing. Why is it so difficult to build a network that does as well as the automated function?

• Did you have a look at the internals of your class? Just do class[[1]] and you can see it all. Currently in 12.2.0.0 (and I think also 12.1) you can extract the internal NetChain from the ClassifierFunction just by doing class[[1]]["Model"]["Network"] . By the way, Classify might also be doing Standardize on your training data too. – flinty Mar 7 at 23:21
• class[[1]] yields what is in the second picture. It is slightly more revealing than Information[] but still very cryptic. – pmac Mar 7 at 23:28
• Does ClassifierInformation not give you what you need? – b3m2a1 Mar 11 at 20:57
• That’s what the first image gives. – pmac Mar 11 at 22:35
• @pmac Classify is not like a black box. class[[1]]["Model"]["Network"] gives you the NetChain used under the hood. Please try your training using net = class[[1]]["Model"]["Network"] and report the accuracy. – flinty Mar 14 at 18:31