# ahmetbekir22/wine-quality-prediction architecture

> Architecture diagram of the GitHub repository ahmetbekir22/wine-quality-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmetbekir22/wine-quality-prediction
- Repository: https://github.com/ahmetbekir22/wine-quality-prediction

## Overview

##### Main System Components
- Data Layer: Represent the wine data stored in the wine_quality_data directory (red and white wine CSV files plus metadata). This is the source of input features.
- Data Analysis & Preprocessing (Optional): While there's no dedicated directory for data transformation, note that the project incorporates feature engineering and preprocessing steps as described in the README.
- Classification Module: This includes the scripts under the classification directory (prediction.py, red_classification.py, white_classification.py) and the corresponding serialized models (classification_red_model.pkl and classification_white_model.pkl). It is responsible for categorizing wine quality into discrete classes (low, medium, high) using a Random Forest approach.
- Regression Module: This includes Python scripts in the regression directory (regression_prediction.py, red_xgboost_model.py, white_xgboost_model.py) and the XGBoost pickle files (xgboost_red_model.pkl and xgboost_white_model.pkl) that are used to predict the wine quality score on a numerical scale.
- Exploratory Analysis: The Jupyter Notebook (white_wine_analays.ipynb) can be depicted as an analysis/visualization component that helps in understanding the dataset and model performance.

##### Relationships/Interactions Between These Components
- Model Prediction: Both classification (using Random Forest) and regression (using XGBoost) components receive preprocessed features. Clearly show their separate logic flows.
- Feedback or Evaluation: Optionally include a component for model evaluation where performance metrics (accuracy, F1 score, R², MSE) are computed, as described in the README.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project splits its core functionality into independent modules for classification and regression.
- Modular Design: Each module (classification and regression) is self-contained, with their own model files and prediction scripts.
- Reusability: The existence of distinct model files (for red and white wines) implies tailor-made pipelines for different wine types. Represent these as sub-components within each module.
- Extensibility: The notebook and structured code-base suggest that future enhancements (e.g., additional preprocessing steps or new model types) can be added without significant rework.

##### Relevant Technologies and Frameworks
- Machine Learning Frameworks: Note (e.g., scikit-learn for Random Forest, XGBoost library for gradient boosting) as part of the underlying technology.
- Model Tuning Tools: Although only mentioned in the README (GridSearchCV for Random Forest, Optuna for XGBoost), include a callout indicating hyperparameter tuning.
- Data Formats: CSV files for the raw data and pickle files (.pkl) for the serialized models.

- Use clear labels for each component. For instance, "Wine Quality Data (CSV)" for the data source, "Feature Engineering" for the preprocessing step, "Random Forest Classifier" under Classification, and "XGBoost Regressor" under Regression.

## Diagram (Mermaid)

```mermaid
flowchart TD
    DATA["Wine Quality Data (CSV)"]:::database
    ANALYSIS["Exploratory Analysis (white_wine_analays.ipynb)"]:::analysis
    FE["Feature Engineering"]:::process
    CONF["Classification Prediction Driver (prediction.py)"]:::service
    CRF_R["Red Wine Classification (RandomForest)\n(red_classification.py)"]:::service
    MODEL_CR_R["Red Classification Model\n(classification_red_model.pkl)"]:::service
    CRF_W["White Wine Classification (RandomForest)\n(white_classification.py)"]:::service
    MODEL_CR_W["White Classification Model\n(classification_white_model.pkl)"]:::service
    REGD["Regression Prediction Driver (regression_prediction.py)"]:::service
    REG_R["Red Wine XGBoost Predictor\n(red_xgboost_model.py)"]:::service
    MODEL_RG_R["Red Regression Model\n(xgboost_red_model.pkl)"]:::service
    REG_W["White Wine XGBoost Predictor\n(white_xgboost_model.py)"]:::service
    MODEL_RG_W["White Regression Model\n(xgboost_white_model.pkl)"]:::service
    EVAL["Evaluation & Metrics"]:::evaluation

    DATA --> FE
    DATA --> ANALYSIS
    FE --> CONF
    FE --> REGD
    CONF --> CRF_R
    CONF --> CRF_W
    CRF_R --> MODEL_CR_R
    CRF_W --> MODEL_CR_W
    REGD --> REG_R
    REGD --> REG_W
    REG_R --> MODEL_RG_R
    REG_W --> MODEL_RG_W
    MODEL_CR_R --> EVAL
    MODEL_CR_W --> EVAL
    MODEL_RG_R --> EVAL
    MODEL_RG_W --> EVAL

    click DATA "https://github.com/ahmetbekir22/wine-quality-prediction/tree/classification/wine_quality_data/"
    click ANALYSIS "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/white_wine_analays.ipynb"
    click CONF "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/classification/prediction.py"
    click CRF_R "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/classification/red_classification.py"
    click CRF_W "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/classification/white_classification.py"
    click MODEL_CR_R "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/classification_red_model.pkl"
    click MODEL_CR_W "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/classification_white_model.pkl"
    click REGD "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/regression/regression_prediction.py"
    click REG_R "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/regression/red_xgboost_model.py"
    click REG_W "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/regression/white_xgboost_model.py"
    click MODEL_RG_R "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/xgboost_red_model.pkl"
    click MODEL_RG_W "https://github.com/ahmetbekir22/wine-quality-prediction/blob/classification/xgboost_white_model.pkl"

    classDef database fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef analysis fill:#aed6f1,stroke:#1f618d,stroke-width:2px;
    classDef process fill:#f0b27a,stroke:#784212,stroke-width:2px;
    classDef service fill:#abebc6,stroke:#117a65,stroke-width:2px;
    classDef evaluation fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
