Skip to content

About

This project demonstrates that while deep learning can provide state-of-the-art results, classical machine learning algorithms remain highly competitive for many practical applications, especially when properly tuned.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Analysis of Model Performance

1. Overfitting vs. Underfitting

Random Forest

  • Training Accuracy: ~94-95%
  • Validation Accuracy: ~76%
  • Initially overfitted (~50-55% validation accuracy), but performance improved significantly after:
    • Tuning max_depth, min_samples_split, and min_samples_leaf to prevent excessive complexity.
    • Increasing n_estimators to 300, stabilizing predictions.
    • Using max_features="sqrt" to reduce variance and improve generalization.

K-Nearest Neighbors (KNN)

  • Training Accuracy: ~78%
  • Validation Accuracy: ~73.5%
  • Originally struggled (~50-55% accuracy) due to high-dimensional noise, but accuracy increased through:
    • Feature selection using SelectKBest, reducing irrelevant features.
    • Applying PCA, reducing dimensions and preventing the curse of dimensionality.
    • Finding the optimal k using GridSearchCV (final best k=11).
    • Scaling data using StandardScaler, ensuring distances were comparable.

XGBoost

  • Training Accuracy: Initially high (~98%), reduced via subsample=0.8, learning_rate=0.01.
  • Validation Accuracy: ~76%
  • Best balance between preventing overfitting and achieving high accuracy.

Neural Networks

  • Basic DNN:

    • Training Accuracy: ~76%
    • Validation Accuracy: ~73%
    • Shows slight overfitting despite dropout and batch normalization.
  • ResNet:

    • Training Accuracy: ~76%
    • Validation Accuracy: ~74%
    • Residual connections helped reduce overfitting compared to Basic DNN.
  • Advanced Model:

    • Training Accuracy: ~78%
    • Validation Accuracy: ~74%
    • Most balanced of the neural networks with best generalization.

2. Confusion Matrix Insights

Model Precision (Bad Wine) Recall (Bad Wine) Precision (Good Wine) Recall (Good Wine)
Random Forest 70% 63% 79% 84%
KNN 69% 59% 77% 84%
XGBoost 70% 64% 80% 84%
Basic DNN 72% 63% 79% 85%
ResNet 72% 60% 78% 86%
Advanced NN 73% 61% 79% 87%
  • Random Forest: Struggles with minority class (bad wines), but has higher precision.
  • KNN: Higher misclassification of bad wines.
  • XGBoost: Best recall for bad wines among classical models.
  • Neural Networks: Slightly better at identifying good wines (higher recall) compared to classical models.
  • Advanced Model: Best overall precision/recall balance with 73% precision on bad wines.

3. Model Comparison: Deep Learning vs. Classical Models

Model Cross-Validation Accuracy Test Accuracy
Random Forest 76.53% 76.79%
KNN 73.47% 74.81%
XGBoost 76.08% 76.41%
Basic DNN N/A 76.69%
ResNet N/A 76.32%
Advanced NN N/A 77.16%

Direct Comparison of Deep Learning vs. Classical Models:

  • Overall Performance: The Advanced Neural Network achieved the highest accuracy (77.16%), outperforming the best classical model (Random Forest at 76.79%) by a small margin of 0.37%.

  • Model Complexity vs. Gain:

    • The Advanced Neural Network has 18,817 parameters compared to Random Forest's simpler structure.
    • This significant increase in complexity resulted in only marginal performance improvement.
  • Training Stability:

    • Neural networks showed more fluctuation during training.
    • Classical models provided more consistent results across cross-validation folds.
  • Prediction Speed:

    • Random Forest and XGBoost made predictions significantly faster than the neural networks.
    • The Basic DNN was the fastest neural network, while ResNet and Advanced Model were slower due to their complexity.
  • Resource Requirements:

    • Deep learning models required much more computational resources for training.
    • Classical models were more efficient and could run effectively with limited hardware.

4. Learning Curve Analysis

  • Random Forest:

    • Training accuracy is stable (~94-95%), while validation accuracy reaches ~76%.
    • Indicates slight overfitting but remains robust.
  • KNN:

    • Training and validation scores increase gradually, suggesting more data could improve performance.
    • Struggles with misclassified minority classes.
  • XGBoost:

    • Initially overfits (~98% training accuracy) but stabilizes at ~76% test accuracy.
    • Shows good generalization when tuned properly.
  • Basic DNN:

    • Training and validation accuracy stabilize around 76% and 73% respectively.
    • Slight gap between curves indicates some overfitting despite regularization.
  • ResNet:

    • Converged faster (around 22 epochs vs 50 for other models).
    • Smaller gap between training and validation accuracy suggests better generalization.
  • Advanced NN:

    • Showed continuous improvement in both training and validation accuracy.
    • Higher final accuracy but with slightly larger training-validation gap.

5. How I Increased Accuracy

Improvements in Classical Models

  • Before Optimization: ~50-55% Accuracy
  • After Optimization: ~76% Accuracy
  • Key Improvements:
    • Hyperparameter Tuning:
      • Optimized key parameters through GridSearchCV.
    • Feature Selection:
      • Selecting top 10 features instead of using all.
    • Stratified Sampling:
      • Ensured balanced class distribution in train-test splits.

Improvements in Neural Networks

  • Before Optimization: ~60-65% Accuracy
  • After Optimization: ~77% Accuracy
  • Key Improvements:
    • Architecture Design:
      • Implemented residual connections to improve gradient flow.
      • Built an advanced model combining the best aspects of different architectures.
    • Regularization:
      • Applied dropout (0.3) and batch normalization to prevent overfitting.
      • Used L2 regularization in the advanced model to further constrain weights.
    • Learning Rate Scheduling:
      • Implemented learning rate decay to fine-tune convergence.
    • Early Stopping:
      • Prevented overfitting by monitoring validation loss and stopping when it stopped improving.

Why These Changes Worked

  • Classical Models: Reducing complexity helped prevent overfitting, improving generalization.
  • Neural Networks: Advanced architectures and regularization techniques allowed deeper models without overfitting.

6. My Conclusions: Why Deep Learning Performed Slightly Better

After implementing and testing multiple models using both classical machine learning and deep learning approaches, I found that the Advanced Neural Network achieved the highest overall accuracy at 77.16%, slightly outperforming Random Forest (76.79%) and XGBoost (76.41%).

Why the Deep Learning Models Performed Better:

  1. Automatic Feature Learning: The neural networks were able to learn subtle non-linear relationships between features without explicit feature engineering. This allowed them to capture interactions that tree-based models might have missed.

  2. Architectural Advantages:

    • The residual connections in the ResNet and Advanced Model helped with gradient flow during backpropagation.
    • Batch normalization stabilized learning, making deeper networks more effective.
    • Dropout helped prevent overfitting, allowing the models to generalize better.
  3. Optimization Techniques: Learning rate scheduling and early stopping helped fine-tune the model training process, finding better local minima in the loss landscape.

Why the Improvement was Marginal:

  1. Dataset Size Limitations: Deep learning typically excels with very large datasets. With our relatively modest wine dataset, the advantage was limited.

  2. Feature Simplicity: Wine quality prediction may not require the complex feature hierarchies that deep learning excels at learning (unlike image or text data).

  3. Classical Model Strengths: Tree-based models like Random Forest and XGBoost are already very good at handling tabular data with mixed feature types and capturing non-linear relationships.

  4. Diminishing Returns: The wine quality prediction task may be approaching its predictive ceiling with the available features, regardless of model sophistication.

Practical Implications:

The minimal performance difference (0.37%) between the best neural network and the best classical model raises important questions about model selection in practice. The neural networks required significantly more computational resources and optimization compared to classical models, yet delivered only incremental improvements.

My final assessment: For this wine quality classification task, I would recommend using the Advanced Neural Network when maximum accuracy is the primary goal. However, if interpretability, deployment simplicity, or computational efficiency is important, Random Forest offers an excellent alternative with only a minimal sacrifice in accuracy.

This project demonstrates that while deep learning can provide state-of-the-art results, classical machine learning algorithms remain highly competitive for many practical applications, especially when properly tuned. For tabular data like the wine dataset, the advantages of deep learning appear to be limited and may not justify the additional complexity and resources required.

Moving forward, I would focus on:

  1. Collecting more data, particularly for underrepresented classes
  2. Exploring ensemble methods that combine classical and neural approaches
  3. Investigating feature engineering techniques to further improve model performance
  4. Testing hybrid models that leverage the strengths of both paradigms

About

This project demonstrates that while deep learning can provide state-of-the-art results, classical machine learning algorithms remain highly competitive for many practical applications, especially when properly tuned.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages