Estimate red-wine sensory quality from routine laboratory measurements
This regression example maps ten physicochemical measurements from Portuguese red Vinho Verde to the panel’s sensory-quality score. On 319 held-out rows, the final 10–10–1 model obtains a Neural Designer goodness-of-fit determination of 0.366, RMSE 0.619 points and 90.9% of estimates within one score point. It supports laboratory pre-screening and lot triage; it does not replace sensory assessment or prove how to improve a formulation.
1. Scientific objective
The objective is to estimate the sensory quality assigned to a red Vinho Verde sample from analytical measurements available during laboratory quality control. The output can help oenologists and quality teams prioritize tasting, investigate atypical lots and compare represented samples consistently. It is a predictive screening model: associations with alcohol, acidity or sulphur dioxide do not establish that changing one variable will cause the score to improve.
Laboratory pre-screening
Flag lots whose analytical profile merits earlier sensory or process review.
Consistency monitoring
Compare an estimated score with panel results and investigate persistent disagreement.
Reproducible benchmarking
Evaluate a compact nonlinear regressor on a widely used oenology data set.
2. Data and provenance
The UCI Wine Quality data set contains physicochemical and sensory results for Portuguese Vinho Verde. This project uses the 1,599 red-wine rows. The target quality is an ordered panel score on a 0–10 scale, although the observed rows cover only scores 3–8.
| Subset | Rows | Purpose |
|---|---|---|
| Training | 961 | Estimate network parameters |
| Selection | 319 | Monitor training and select hidden-layer size |
| Testing | 319 | Final internal evaluation |


Analytical fields and model contract
| Field | Unit or scale | Use in this project |
|---|---|---|
fixed_acidity | g tartaric acid/dm³ | Present in CSV; imported as the sample-ID field and therefore excluded from the model |
volatile_acidity | g acetic acid/dm³ | Input |
citric_acid | g/dm³ | Input |
residual_sugar | g/dm³ | Input |
chlorides | g sodium chloride/dm³ | Input |
free_sulfur_dioxide | mg/dm³ | Input |
total_sulfur_dioxide | mg/dm³ | Input |
density | g/cm³ | Input |
pH | Dimensionless | Input |
sulphates | g potassium sulphate/dm³ | Input |
alcohol | % vol | Input |
quality | Panel score, 0–10 | Target; observed range 3–8 |
winequality.csv is the exact 1,599-row table used by the stored project. Its local and published copies have matching SHA-256 hashes.
3. Model
The baseline network standardizes ten inputs, applies one dense layer with three tanh neurons and returns one continuous quality estimate through an identity neuron, output unscaling and bounds of 3–8. The initial 10–3–1 architecture contains 37 trainable parameters.

4. Training strategy
The baseline minimizes normalized squared error with L2 regularization using the Quasi-Newton method. Across 81 epochs, training error falls from 0.9987 to 0.5547 and selection error from 0.3696 to 0.2208.

5. Model selection and baseline
The growing-neurons task evaluates one to 20 hidden neurons. The lowest stored selection error is 0.2182 at ten neurons, only slightly below neighbouring candidates. Because the curve is nearly flat and the search reaches its configured maximum, ten neurons should be read as the selected run—not as proof of a uniquely optimal architecture.

Selected architecture
The final model expands the hidden layer from three to ten tanh neurons. The 10–10–1 network contains 121 trainable parameters and is the model used for testing, the browser calculation and the downloadable Python export.

| Reference | Testing RMSE | Reading |
|---|---|---|
| Training-mean baseline | 0.771 | One constant estimate for every test row |
| Final neural network | 0.619 | 19.7% lower RMSE than the null baseline |
6. Scientific validation
The final model is evaluated on the 319 testing rows after neuron selection. Neural Designer’s linear goodness-of-fit analysis reports a determination coefficient of 0.366. Directly recomputing residual metrics from the same exported model gives RMSE 0.619, MAE 0.486 and mean signed error −0.053 score points.
| Testing measure | Result | Professional reading |
|---|---|---|
| GOF determination | 0.366 | Moderate association between observed and predicted scores |
| RMSE | 0.619 | Penalizes the larger misses |
| MAE | 0.486 | Typical absolute miss is about half a score point |
| Mean signed error | −0.053 | Small aggregate bias can hide strong score-dependent bias |
| Within ±1 point | 90.9% | 290 of 319 testing estimates |
Error by observed score
| Observed score | Testing rows | MAE | Mean signed error |
|---|---|---|---|
| 3 | 1 | 2.105 | +2.105 |
| 4 | 6 | 1.259 | +1.259 |
| 5 | 132 | 0.360 | +0.318 |
| 6 | 135 | 0.455 | −0.238 |
| 7 | 42 | 0.789 | −0.788 |
| 8 | 3 | 1.110 | −1.110 |

7. Inference and reproducibility
A professional workflow starts with a traceable lot and validated laboratory results, reproduces the ten-field schema, calculates an estimate, compares it with historical and sensory-panel evidence, and records the model version and any warning.
Try the exported red-wine quality estimator
The defaults reproduce a held-out record with an observed sensory score of 6. The exact exported model estimates 6.01.
Reproduce the calculation
The Python package contains the exact final export, ordered input schema, representative testing row and example call.
from model import NeuralNetwork
inputs = [0.34, 0.42, 2.0, 0.086, 8.0, 19.0, 0.99546, 3.35, 0.6, 11.4]
estimated_quality = NeuralNetwork().calculate_outputs(inputs)[0]
print(estimated_quality) # 6.00704497048. Validity, uncertainty and limitations
- Internal random split only. No independent winery, harvest, geography or later-vintage validation is shown.
- Duplicate leakage. Seventy-six testing rows have an exact duplicate in another subset, so the stored split can overstate transfer to new lots.
- One data collection. Results cannot be assumed to transfer to white wine, other appellations, grape varieties, laboratories or analytical protocols.
- Sensory labels are subjective and discrete. Panel composition, repeatability and disagreement are not available, and an ordinary regressor does not explicitly model the target’s ordinal structure.
- Rare-score performance is weak. Only ten score-3 and eighteen score-8 records exist in the full table; the test set contains one and three respectively.
- Current import excludes fixed acidity. The stored project treats the first CSV field as a sample identifier. A full 11-feature experiment requires re-importing the file without that setting and regenerating every dependent artifact.
- No causal optimization. Directional outputs or response optimization would describe the fitted associations only; proposed process changes need designed experiments and oenological review.
References
- UCI Machine Learning Repository: Wine Quality (DOI: 10.24432/C56S3T; CC BY 4.0).
- P. Cortez, A. Cerdeira, F. Almeida, T. Matos and J. Reis, Modeling wine preferences by data mining from physicochemical properties, Decision Support Systems 47(4), 547–553 (2009).


