Using MLPregressor to get the confidence vector of MLPclassifier

Dear all

Someone asked on our GitHub if it was possible for FluidMLPClassifier to provide its confidence vector. The answer is that there is another way: since the MLP code is the same under the hood, one can load a model made in the classifier in the regressor and get access to the output vector, in effect a histogram of how much each class is likely to be the right one.

Here it is in Max first - I am using the demo code from the classifier tutorial. I will code the SC version later from the video code again.

classification-video-demo+vector-from-regressor.maxpat (20.2 KB)

1 Like

and here is the SC code. First download the code from the video and run it so you have a classifier working: Classifying Sounds using a Neural Network in SuperCollider - YouTube

then use this and it works mightily!

// import the classifier state as a dictionary
~nn.dump{|i|~nn_dump = i}

// check the content - there is a dictionary called mlp
~nn_dump.post
~nn_dump["mlp"].post

// make a regressor
~reg = FluidMLPRegressor(s)
// load the fitted state
~reg.load(~nn_dump["mlp"])

//check it works
~confidences = Buffer.alloc(s,2);
~realtime_analysis.(~trombone_test);
~realtime_analysis.(~oboe_test);

(
~reg.predictPoint(~mfccbuf, ~confidences, {
	~confidences.getn(0,2,{|i|i.postln});
});
)
1 Like

Hi temblap!
Thank you so much. this is helping a lot!!
We tried out your max patch but after switching on the predictpoint-toggle – the mlpregressor was telling us “Input tab too large”. What can we do?
Warmly
Thomas & Jakob

I need to test the patch now, it might be out of date - there was a change of interface at one point. Stay tuned.

ok this works now - a few unplugged things that the max window moaned about.

classification-video-demo+vector-from-regressor.maxpat (19.6 KB)

Thank you! We tried your patch – Now, it seems to work but there are some new questions. The classifier is learning a lot slower and lands at an error of 0.01 when it usually has been around 0.0001. Also the numbers coming out of the regressor are very inconsistent and seem to stutter a lot. Maybe this procedure needs a lot more computer power?

Many ambiguities in your message.

Slower than what?

Error - you didn’t save the training? did you try re-seeding (with clear)? Did you read the learn.flucoma.org resource on MLP?

Computer power - it depends. more than what? comparing what?

Looking forward to have a little more precision to try to help you…