Skip to content
nickgillian edited this page Aug 21, 2016 · 14 revisions

##Adaptive Naive Bayes Classifier (ANBC)

##Description The Adaptive Naive Bayes Classifier (ANBC) is a naive but powerful classifier that works very well on both basic and more complex recognition problems.

The ANBC algorithm is a supervised learning algorithm that can be used to classify any type of N-dimensional signal. The ANBC algorithm works by fitting an N-dimensional Gaussian distribution to each class (i.e. gesture) during the training phase. New gestures can then be recognized in the prediction phase by finding the gesture that results in the maximum likelihood value (given the new sensor data and each of the Gaussian distributions). The ANBC algorithm also computes rejection thresholds that enable the algorithm to automatically reject sensor values that are not the K gestures the algorithm has been trained to recognized (without being explicitly told during the prediction phase if a gesture is, or is not, being performed).

Gaussian Distribution

  • Upper plot: two Gaussian distributions (red and green dotted lines) estimated from the training samples (red and green dots).
  • Lower plot: probability for each of the two classes. Gaussian Distribution
  • Upper plot: two Gaussian distributions (red and green dotted lines) estimated from the training samples (red and green dots).
  • Lower plot: probability for each of the two classes.

In addition, the ANBC algorithm enables you to weight the importance of each dimension for each gesture. For instance, imagine that you want to create a recognition system that can recognize a user's left-handed gestures, right-handed gestures, and two-handed gestures. To track the user's movements you use a depth sensor and skeleton-tracking algorithm that can track any user who stands in front of the depth sensor and sends out the x-y-z joint position of the user's two hands (along with the user's other joints) at 30Hz. You use the 3-dimensional joint data for each hand to create a 6-dimensional vector (containing {leftHandX, leftHandY, leftHandZ, rightHandX, rightHandY, rightHandZ}) as input to the ANBC algorithm. The ANBC algorithm enables you to weight each dimension of this vector for each of the 3 types of gestures you want to recognize (i.e. left-handed, right-handed, and two-handed gestures), so for a left-handed gesture you would set the weights for this class to {1,1,1,0,0,0}, for the right-handed gesture you would set the weights for this class to {0,0,0,1,1,1}, and for the two-handed gesture you would set the weights for this class to {1,1,1,1,1,1}. You only need to set these weights values once, before you train the ANBC model, the weights will then automatically be incorporated into the Gaussian models for each gesture (and therefore nothing special needs to be done for the prediction phase). You can set the weights using the setWeights(ClassificationData weightsData) function.

You can find out more about the ANBC algorithm in Gillian, N. (2011) An adaptive classification algorithm for semiotic musical gestures.

The ANBC algorithm is part of the GRT classification modules.

##Advantages The ANBC algorithm is a very good algorithm to use for the classification of static postures and non-temporal pattern recognition. For example, detecting the orientation of a device embedded with an accelerometer or recognizing that a user is standing with their arms down by their waist with a depth camera and skeleton data.

##Disadvantages The main limitation of the ANBC algorithm is that, because it uses a Gaussian distribution to represent each class, it does not work well when the data you want to classify is not linearly separable and/or the data has a multimodal distribution. If this is the case with your data then you might want to try a Support Vector Machine instead.

##Toy Data

3 class linearly separable 3 class nonlinearly separable
3 class xor 3 class donut

The images above show the ANBC algorithm applied to four basic datasets. These datasets highlight several strengths and weaknesses for the ANBC algorithm.

  • 3 class linearly separable: the ANBC algorithm has no problem for this type of multiclass linearly separable task.
  • 3 class nonlinearly separable: this type of problem raises some challenges for the ANBC algorithm, as the Gaussian model is not able to generalize to this type of data.
  • XOR: the ANBC algorithm completely fails for this type of problem, this is due to the algorithm's assumption that the distribution generating the data is uni-modal.
  • 3 class Donut: the ANBC algorithm can generalize for this type of problem. At first, this might be surprising, because the problem is clearly not linearly separable. However, to the ANBC algorithm, this data is linearly separable, due to the Gaussian distribution at the core of the algorithm. Measuring the data from some central point results in the red class having a low (squared) distance to the central point, with the green and blue classes having much larger (squared) distances. This is exactly what the Gaussian model is doing, hence why the data is linearly separable for the ANBC algorithm.

##Training Data Format You should use the ClassificationData data structure to train the ANBC classifier.

##Example Code ANBC Example