# Cascaded Machine-Learning Technique for Debris Classification in Floor-Cleaning Robot Application
## 4 Methodology
### SVM for Error Reduction and Spill Size-Based Classification  
Not all liquid spillage debris are hard to clean. While a robot may not be able to clean the solid debris, it should also not make a mess out of it. However, the same is not the case with liquid spills, where a classifier based on the spill size is required to prevent a mess and damage to cleaning equipment. Here, SVM is employed to classify the size of liquid spillage debris detected. SVM would have a higher accuracy over a fixed threshold, which may not accurately determine the border cases. Also, SVM is lightweight on computational requirements, which helps for real-time implementation of this scheme. A soft margin SVM is used. The hyperplane boundary is modeled into a minimization problem shown in Equation (9). \[f(x)=[\frac{1}{n}\times\sum max(0,1-y_{i}(\vec{m}.\vec{x_{i}}-b))]+\lambda|| \vec{m}||^{2} \tag{9}\]  
where \(||\vec{m}||^{2}\) is a term used adjusting the margin size of a soft margin SVM classifier. Also, since the data is not linearly separable, a RBF kernel is used. The RBF kernel \(K\) on two points \(x_{1}\) and \(x_{2}\) is given in Equation (10). \[K(x_{1},x_{2})=\exp{(-\frac{||x_{1}-x_{2}||^{2}}{2\sigma^{2}})} \tag{10}\]  
where \(\sigma\) is a free parameter. Two viewpoints are used in this paper for spill size detection, i.e., viewing from a top perspective and viewing from a robot's perspective. For both perspectives, three features--Area, Class, and Confidence are used in this classification. **Area:** The area is used as a measure of the size of the spill. The area is estimated using a transformation as given in Equation (11). \[Area=Width_{real}\times Height_{real} \tag{11}\]  
\[Width_{real}=Width_{box}\times PPI \tag{12}\]  
\[Height_{real}=Height_{box}\times PPI \tag{13}\]  
\[PPI=\frac{Width_{image}\times Height_{image}}{Width_{area}\times Height_{ area}} \tag{14}\]  
where \(Area\) is the estimated area, \(Width_{real}\) and \(Height_{real}\) are the real width and height computed from Equations (12) and (13). These equation use Pixel Per Inch(PPI), computed by Equation (14). \(Width_{image}\) and \(Height_{image}\) are the height and width of the captured image in pixels. \(Width_{area}\) and \(Height_{area}\) are the height and width of the area corresponding to the image in inches. **Class and Confidence:** These measures are obtained from the SSD MobileNet network. These measures along with calculated area are used to filter out certain misclassifications or false detections such as floor patterns or small stains spread randomly on the floor. The Algorithms 1 and 2 represent the pseudocode for training and running the model of proposed scheme. A pseudocode of the algorithm used for training the CNN and running the model is shown in Algorithms 1 and 2. The function \(LOAD()\) loads the model into memory, \(TRAIN()\) trains the model with the parameters specified. The remaining parameters are inherited from the model. The function \(UPDATEMETRICS()\) updates the accuracy, precision, and recall based on the new predictions. The final accuracy, precision, recall are \(acc,prec,rec\). The function \(model_{SVM}\) is trained in a similar fashion but using only liquid spill size data.