# Classification of Trash and Valuables with Machine Vision in Shared Cars
## 3 Results
### Fine-Tuned VGG16 Prediction Model  
In the final architecture of the VGG16 model, SoftMax activation was used. The conversion of the vector values, by the SoftMax function, to corresponding probabilities of the three output classes can be described by  
\[\mathrm{P}(y_{i})=\frac{\mathrm{e}^{y_{i}}}{\sum_{j}\mathrm{e}^{y_{j}}}, \tag{1}\]  
where \(y\) is the input value of the vector from the previous layer and \(\mathrm{P}(y_{i})\) is the probability of this input value. The variables \(i\) and \(j\) are the indices of the vector and sum, respectively. Furthermore, Rectified Linear Unit (ReLu) activation was associated with each activation compatible hidden layer of the CNN. Stochastic Gradient Descent (SGD) with a momentum of 0.9 was chosen as the optimizer of the network due to its observed capability of producing better results when updating the weights of the CNN throughout the training epochs. The loss function for the CNN was categorical cross-entropy since the model corresponded to a classification problem with three possible output classes. Since it was important to ensure that the loss magnitude did not exponentially increase over specific bounds during training, L2 regularization (adding squared coefficients to the loss function) was also integrated into the architecture of the model. Regularization was used for all regularization compatible hidden layers with a constant value of 0.001. Additionally, a learning-rate scheduler was utilized in the form of a step decay function as a measure to control the learning rate during the training of the model. The equation of the learning rate used yields to:  
\[lr=id^{\frac{1+\alpha}{\alpha\beta\cdot}}, \tag{2}\]  
where \(lr\) is the learning rate, \(i\) is the initial learning rate (0.001), \(d\) is the fraction by which the learning rate reduces (0.1), \(ep\) is the current epoch, and \(ep\_s\) is the number of epochs, which should be completed before changing the value of the learning rate (40). The model was trained using a range of hyperparameter combinations, with observations on the variation in the training and testing plots with respect to the loss and accuracy. The total number of training epochs was set to 120 (without early stopping) and batch sizes of 300, 108 and 140 were used for the training, validation and testing sets, respectively. Figure 7 illustrates the final plot once the desired accuracy of the model was reached. Note that the validation error fluctuates during training. Specifically, this fluctuation is primarily due to the validation set not being an ideal representation of the whole dataset used for training. The validation accuracy on the other hand increases and eventually saturates at the point where the training accuracy and the training loss become stable (which is the behaviour we intended to see). The contrast between the validation loss and the validation accuracy in our results was a unique case. The difference can be related to the manner by which the values are calculated for each epoch in which the validation loss corresponds to a loss function while the validation accuracy corresponds to an accuracy metric during the compilation of the model in Tensorflow. The limitation of the dataset requirements here is therefore evident from the validation plots, which indicate slight overfitting due to a quantitative bias among certain item categories used in the current research. Thus, we are able to confirm the requirement for expanding the dataset for attaining a better ability of the model to generalize for a larger variety of potential leftover items (specifics of the future research is addressed in the conclusion). Figure 8 shows the final confusion matrix, and this corresponded to the correlation between the predicted classes and the ground truth for the test batch of images. The final accuracy of the batch of 140 test images was observed to be 91.43%. Two files were generated as outputs to further examine the test results. One file listed the correct classifications, while the other listed the incorrect ones.