hf_mirrors/p3-wine-quality-keras-ensemble-mixed-top5
Model Introduction
Files & versions
Analysis
You are visiting the mirror address of https://huggingface.co/neck392/p3-wine-quality-keras-ensemble-mixed-top5. The repo is synchronized in real-time and is only for mirror acceleration access.

P3 Wine Quality Prediction - Keras Ensemble Mixed Top5

This repository contains the final selected Keras ensemble model developed for wine quality prediction.

The ensemble predicts wine quality from 11 physicochemical input features. Each member model first produces a continuous regression output. The final ensemble prediction is calculated by averaging the continuous outputs of the five selected member models, followed by threshold-based integer quality conversion.

Selected Ensemble

  • Selected ensemble: Ensemble_Mixed_Top5
  • Number of member models: 5
  • Aggregation method: mean of continuous regression outputs
  • Threshold tuning: validation-based coordinate search
  • Output: continuous prediction and integer wine quality label

Member Models

  • Q_MLP_32_16_Huber
  • Q_MLP_16_8
  • Q_MLP_32
  • Q_MLP_64
  • AEPC_MLP_64

Dataset Summary

  • Data shape: (4898, 12)
  • Input features: 11
  • Target variable: quality
  • Theoretical quality range: 0 to 10
  • Observed quality range: 3 to 9

Input Features

  1. fixed acidity
  2. volatile acidity
  3. citric acid
  4. residual sugar
  5. chlorides
  6. free sulfur dioxide
  7. total sulfur dioxide
  8. density
  9. pH
  10. sulphates
  11. alcohol

Preprocessing

Two preprocessing strategies are used across the ensemble member models.

Quantile 1%~99% Clipping

This preprocessing strategy clips selected feature values using the 1st and 99th percentiles computed from the training set. It then applies log1p transformation to selected skewed features and StandardScaler normalization.

AEPC: Adaptive Excess-Preserving Clipping

AEPC is a project-designed preprocessing strategy for handling upper-tail extreme values. Instead of fully cutting values above a cap, AEPC compresses the excess part while preserving a controlled portion of the original extreme-value signal.

For a value above the AEPC cap, the adjusted value is computed as:

adjusted_value = cap + alpha * (original_value - cap)

Here, alpha controls how much of the excess signal is preserved. The value of alpha is determined from upper-tail characteristics such as tail ratio, target signal, and tail continuity. This makes AEPC less aggressive than hard clipping while still reducing the influence of extreme values.

Log-transformed Features

['chlorides', 'volatile acidity', 'free sulfur dioxide', 'citric acid', 'residual sugar']

Thresholds

The selected threshold values are:

[3.5, 4.4, 5.65, 6.55, 7.35, 8.5]

Performance

Selected Ensemble Performance

SplitRMSE RawMAE RawR2 RawAccuracyKappaMAE_intMacro F1Weighted F1
Validation0.6898500.5315970.3915910.5775510.3446540.4653060.2969270.555434
Test0.6939020.5399580.3866280.5724490.3393060.4693880.2778220.552183

Model Comparison Note

Compared with the final single model, the selected ensemble improved integer quality prediction performance. The final single model achieved a test accuracy of 0.560204, test kappa of 0.310787, and test MAE_int of 0.492857, while this ensemble achieved a test accuracy of 0.572449, test kappa of 0.339306, and test MAE_int of 0.469388.

Repository Files

FileDescription
models/Trained Keras member models
preprocess/Preprocessing scalers and transformation parameters
ensemble_config.jsonEnsemble configuration and selected thresholds
preprocess_config.jsonDataset, preprocessing, and training configuration
metrics.jsonEvaluation metrics
member_model_results.csvRaw regression results of the five member models
confusion_matrix_selected.csvConfusion matrix of the selected ensemble
classification_report_selected.txtClassification report of the selected ensemble
inference.pyExample inference script
requirements.txtRequired Python packages

Example Usage

from inference import predict_quality

sample = {
    "fixed acidity": 7.0,
    "volatile acidity": 0.27,
    "citric acid": 0.36,
    "residual sugar": 20.7,
    "chlorides": 0.045,
    "free sulfur dioxide": 45.0,
    "total sulfur dioxide": 170.0,
    "density": 1.001,
    "pH": 3.00,
    "sulphates": 0.45,
    "alcohol": 8.8
}

result = predict_quality(sample)
print(result)

Limitations

The dataset is concentrated around middle quality scores, especially 5 and 6. As a result, predictions for rare extreme quality scores may be less reliable.

The ensemble can improve prediction stability by averaging multiple member models, but it may still have difficulty predicting rare extreme quality labels.