Wine Quality Prediction by Integrating SQL-Based Feature Engineering and Random Forest Modeling
Abstract
Traditional wine quality assessment based on tasters is costly and subjectively inconsistent, making it difficult to meet the needs of automated quality control for large volumes of data. This study imports the 1,143-record WineQT dataset into MySQL, checks data quality, and constructs two SQL-derived features before six-class modeling. The initial row-wise split gave the full-feature random forest an accuracy of 0.7118 and a macro-F1 of 0.3415. A later audit, however, identified 125 repeated rows. Among these, 43 test records had identical counterparts in the training set. Keeping identical observations in the same group reduced accuracy to 0.5721 and macro-F1 to 0.2713, providing a more conservative estimate. In repeated stratified group five-fold cross-validation, the original features achieved 0.5984±0.0300 accuracy and 0.2793±0.0218 macro-F1; adding the SQL-derived features produced no improvement. Class weighting raised macro-F1 but lowered accuracy and weighted-F1. SQL therefore contributes mainly through consistent data checks, feature definitions, and a more traceable evaluation process.
References
- Cortez, P., Cerdeira, A., Almeida, F., et al. (2009). Modeling wine preferences by data mining from physicochemical properties.Decision Support Systems, 47(4), 547–553. https://doi.org/10.1016/j.dss.2009.05.016
- Jain, K., Kaushik, K., Gupta, S. K., et al. (2023). Machine learning-based predictive modelling for the enhancement of wine quality.Scientific Reports, 13, Article 17042. https://doi.org/10.1038/s41598-023-44111-9
- Bhardwaj, P., Tiwari, P., Olejar, K., et al. (2022). A machine learning application in wine quality prediction.Machine Learning with Applications, 8, Article 100261. https://doi.org/10.1016/j.mlwa.2022.100261
- Zaza, S., Atemkeng, M., & Hamlomo, S. (2023). Wine feature importance and quality prediction: A comparative study of machine learning algorithms with unbalanced data.arXiv. https://arxiv.org/abs/2310.01584
- Chen, Z. (2025). Wine quality prediction with ensemble trees: A unified, leak-free comparative study.arXiv. https://arxiv.org/abs/2506.06327
- Yasser, H. M. (2022). Wine quality dataset [Data set].Kaggle. https://www.kaggle.com/datasets/yasserh/wine-quality-dataset
- Breiman, L. (2001). Random forests.Machine Learning, 45(1), 5–32. https://doi.org/10.1023/A:1010933404324
- Pedregosa, F., Varoquaux, G., Gramfort, A., et al. (2011). Scikit-learn: Machine learning in Python.Journal of Machine Learning Research, 12, 2825–2830.
- He, H., & Garcia, E. A. (2009). Learning from imbalanced data.IEEE Transactions on Knowledge and Data Engineering, 21(9), 1263–1284. https://doi.org/10.1109/TKDE.2008.239
- Kulasiri, D., Somin, S., & Kumara Pathirannahalage, S. (2024). A machine learning pipeline for predicting Pinot Noir wine quality from viticulture data: Development and implementation.Foods, 13(19), Article 3091. https://doi.org/10.3390/foods13193091