CoolFace
Modelpublic

neck392/p3-wine-quality-keras-mlp32-16-huber-tuned

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes6downloads
Model Card

P3 Wine Quality Prediction - Keras MLP32-16 Huber Tuned

This repository contains a Keras-based MLP model developed for wine quality prediction.

The model predicts wine quality from 11 physicochemical input features. It first produces a continuous regression output and then applies threshold-based post-processing to convert the output into an integer wine quality label.

Model Summary

  • —Framework: TensorFlow / Keras
  • —Model type: Multi-Layer Perceptron
  • —Hidden layers: 32-16
  • —Activation: ReLU
  • —Loss function: Huber loss, delta=1.0
  • —Optimizer: Adam
  • —Learning rate: 0.001
  • —Batch size: 32
  • —Maximum epochs: 500
  • —Early stopping patience: 30
  • —Epochs trained: 84
  • —Target variable: quality
  • —Theoretical quality range: 0 to 10
  • —Actual quality range in the dataset: 3 to 9

Input Features

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

Preprocessing

The preprocessing pipeline follows the same experimental setting used during model development.

  1. 1.1st to 99th percentile clipping based on the training data
  2. 2.log1p transformation for selected skewed features
  3. 3.StandardScaler normalization
  4. 4.Keras MLP regression prediction
  5. 5.Clipping continuous predictions to the 0-10 range
  6. 6.Threshold-based integer quality conversion

Clipped Features

~~~text ['fixed acidity', 'volatile acidity', 'citric acid', 'residual sugar', 'chlorides', 'free sulfur dioxide', 'total sulfur dioxide', 'density', 'pH', 'sulphates'] ~~~

Log-transformed Features

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

Thresholds

The threshold values selected on the validation set are:

~~~text [3.5, 4.5, 5.65, 6.6, 7.5, 8.5] ~~~

Performance

Raw Regression Performance

SplitRMSEMAER2
Validation0.7058700.5455590.363006
Test0.7159660.5550120.347002

Threshold-Tuned Integer Quality Performance

SplitAccuracyKappaMAE_intMacro F1Weighted F1
Validation0.5704080.3254820.4744900.2867250.543393
Test0.5602040.3107870.4928570.2724810.536417

Model Selection Note

Although MLP168 achieved the lowest validation RMSE among raw regression models, this MLP32-16 Huber model was selected as the final single model because it achieved better threshold-tuned integer quality prediction performance on the validation set.

Repository Files

FileDescription
model.kerasTrained Keras model
scaler.pklFitted StandardScaler object
clip_bounds.jsonClipping bounds computed from the training data
log_config.jsonLog transformation configuration
feature_columns.jsonInput feature order
thresholds.jsonThreshold values for integer quality conversion
preprocess_config.jsonPreprocessing and model configuration
metrics.jsonEvaluation metrics
inference.pyExample inference script
requirements.txtRequired Python packages

Example Usage

~~~python 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.