How to get classification probabilities from MultilayerPerceptronClassifier?

爱⌒轻易说出口 提交于 2019-12-01 19:32:15

If you take a look at this line in the MLPC source code, you can see that the MLPC is working from an underlying TopologyModel which provides the .predict method I'm looking for. The MLPC decodes the resulting Vector into a single label.

I'm able to use the trained MLPC model to create a new TopologyModel using its weights:

MultilayerPerceptronClassifier trainer = new MultilayerPerceptronClassifier()...;
MultilayerPerceptronClassificationModel model = trainer.fit(trainingData);
TopologyModel topoModel = FeedForwardTopology.multiLayerPerceptron(model.layers(), true).getInstance(model.weights());

I think the short answer is No.

The MultilayerPerceptronClassifier is not probabilistic. When the weights (and any biases) are set after training, the classification for a given input will always be the same.

What you're really asking, I think, is "if I were to tweak the weights by certain random disturbances of a given magnitude, how likely would the classification be the same as without the tweaks?"

You could do an ad hoc probability calculation by re-training the perceptron (with different, randomly chosen starting conditions) and get some idea of the probability of various classifications.

But I don't think this is really part of the expected behavior of a MLPC.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!