Inference in the image classifier exampleNow we have the models in place, let's look what happens when a user of our application drags an image to the green or red area. When the user releases the left mouse button after doing the drag, a MouseLeftButtonUp event will occur. This event is handled by the Rectangle_MouseLeftButtonUp method in the ClassifierView class. This method checks to see if the state of the image items has changed (i.e. whether labels have changed) and if yes, then calls into the Reclassify method of the ItemsModel class. The Reclassify method, which is the glue between the user interface and the inference, does the following:
The user interface code then updates the positions of all the test images, so that their horizontal coordinate represents the probability calculated in step 3. Now let's look at the Train and Test methods in steps 2 and 3. The BayesPointMachine Train method looks as follows:
The first three lines are setting the given values required by the model. The final line does the inference and retrieves the inferred posterior weights and sets the given posterior weights for the test model. The very first time this is run the Bayes Point Machine is compiled and there is a slight delay, but thereafter, the response time of the inference is not noticeable. The BayesPointMachine Test method looks as follows:
|


