@@ -116,12 +116,26 @@ The following table summarizes the performance of different baseline models on t
### Random Forest
### CNN
### CNN (Convolutional Neural Network)
Convolutional Neural Networks (CNNs) are a class of deep neural networks, highly effective for analyzing visual imagery. CNNs are particularly suited for image classification because they can automatically and adaptively learn spatial hierarchies of features from input images. This makes them capable of learning directly from raw images, eliminating the need for manual feature extraction.
#### How CNNs Work
CNNs are composed of multiple layers, including convolutional layers, pooling layers, and fully connected layers. The convolutional layers apply a series of filters to the input image, each filter detecting a specific feature. The pooling layers then downsample the feature maps, reducing their dimensionality. The fully connected layers then process the high-level features and make the final classification.
#### Expected Results
The CNN model is expected to outperform the baseline models and the basic classifiers (Naive Bayes, Decision Trees, and Random Forest) due to its higher capacity to learn complex features from images. CNNs are particularly effective for image classification tasks, and we anticipate that our CNN model will achieve the highest accuracy among all the models we've implemented.
## Experiments and results
### Overview
We have conducted a series of experiments to evaluate the performance of different classifiers on our fruit image classification task. These experiments involve testing various feature combinations, hyperparameters, and picture sizes to identify the optimal model configuration. The results of these experiments are presented below, providing insights into the performance of each classifier and the impact of different configurations on the model's accuracy.
To reproduce the results, please refer to the README in the src folder for instructions on how to run the experiments.
### Feature Engineering
- we are experimenting with different feature combinations, which can be used as an input parameter for our `classify_images.py` script
@@ -252,17 +266,48 @@ Results for RandomForestClassifier classifier on 100x100_standard images:
We have implemented a Convolutional Neural Network (CNN) for our fruit image classification task. The CNN model consists of multiple layers, including three convolutional layers and pooling layers, a dropout layer and two fully connected layers with one of them being the output layer which uses the softmax function. The model architecture is a basic one and could be further optimized by changing the number of layers, the number of filters, the kernel size, the activation function, the dropout rate, etc.
#### Testing Results
### Final results
The CNN model achieved an accuracy of **0.68** on the development set. This is a significant improvement over the baseline models and the basic classifiers. The model's performance on the training set was a little higher, with an accuracy of **0.83**. This suggests that the model is not overfitting, and it is learning effectively from the training data. The model's performance on the test set is expected to be similar to the development set, given the balanced nature of our dataset.
Having tested different feature combinations, hyperparameters and picture sizes on the development set, we have found our optimal parameters for the final tests on the **test set**.
The learning curve of the CNN model shows that the model is learning effectively from the training data, with the training and validation loss decreasing and the accuracy increading over time. Also we can see that after about 25-30 Epochs the model reaches its best performance and the training stagnates.
The confusion matrix of the CNN model shows that the model is performing well across all classes, with high accuracy for most classes. The model's performance is consistent across most classes, with some problems in distinguishing between similar classes, such as mandarins, oranges and grapefruits. Also the mandarine class is the one with the lowest accuracy because it is underrepresented in the dataset.
With looking at some of the images that were misclassified, we can see that the model is sometimes confused by the similar shape and color of the fruits. For example, as stated, the model often confuses mandarins, oranges and grapefruits
Having tested different feature combinations, hyperparameters and picture sizes on the development set, we have found our optimal parameters for the final tests on the **test set**. The results are presented in the following diagram:

The CNN model achieved the highest accuracy of **0.68**, followed by the Random Forest model with an accuracy of **0.48**. The Naive Bayes and Decision Tree models achieved the lowest accuracies, with **0.18** and **0.39**, respectively. The Random Forest model's performance is particularly noteworthy, as it achieved an accuracy of **0.48** using the HSV feature combination on 50x50 images. This is a significant improvement over the baseline models and the basic classifiers, demonstrating the effectiveness of the Random Forest model for our fruit image classification task. The CNN model's performance is also impressive, achieving an accuracy of **0.68**. This is a testament to the effectiveness of CNNs for image classification tasks, and it reinforces the suitability of CNNs for our fruit image classification task.
The performance on the dev and test set is (as expected) nearly the same, which is a good sign that the model is not overfitting and again shows the balanced nature of our dataset.
### Feature Importance
### Data Reduction
We have also tested training a random forest model and a CNN model on a reduced dataset size. In the Diagram below you can see the results of the tests. The results show that the performance of the models decreases with a reduced dataset size but we can still achieve a good performance with 50% or more of the original dataset size.