Drowsiness (Sleep) Detection Using Machine Learning – Part 2 of 5

 Drowsiness (Sleep) Detection Using Machine Learning – Part 2 of 5

The cascade classifier consists of a set of stages, where each stage is an ensemble of weak learners. These are called decision stumps. Each stage is trained to employ a technique called boosting. Boosting provides the power to coach a highly accurate classifier by taking a weighted average of the choices made by the weak learners.

Each stage of the classifier labels the region defined by the present location of the window as either positive or negative. When an object was found, it indicates as Positive and negative indicates when no objects were found. If the label is negative, the classification of this region is complete, and therefore the detector slides the window to the subsequent location. If the label is positive, the classifier passes the region to a subsequent stage. The detector reports an object found at the present window location when the ultimate stage classifies the region as positive. To reject negative samples as fast as possible, the stages are designed. The assumption is that the vast majority of windows do not contain the object of interest. Conversely, true positives are rare, and price taking the time to verify.

  • A true positive occurs when a positive sample is correctly classified.
  • A false positive occurs when a negative sample is mistakenly classified as positive.
  • A false negative occurs when a positive sample is mistakenly classified as negative.

To work well, each stage within the cascade must have a false-negative rate. If a stage incorrectly labels an object as negative, the classification stops, and you can’t correct the error. But each stage can have a false-positive at a higher rate. Even if the detector incorrectly labels a non-object as positive, you’ll correct the error in subsequent stages. Adding more stages reduces the general false-positive rate, but it also reduces the general true positive rate. Cascade classifier training requires a group of positive samples and a group of negative images. You must provide a group of positive images with regions of interest specified to be used as positive samples. You can use the Image Labeler to label objects of interest with bounding boxes. The Image Labeler is there to output a table to use in positive samples. You also must provide a group of negative images from which the function generates negative samples automatically. To achieve acceptable detector accuracy, set the number of stages, feature type, and other functional parameters.

This is the second out of a series of five articles. See you tomorrow with more! Stay tuned!!!

Day 01

Day 02

Day 03 –

Day 04 –

Day 05 –

Full code available at:


Comments are closed.