Predicting Wine Quality
What determines an excellent wine?
Tons of work goes into producing just one bottle of wine. The best ingredients, the right fermentation environment and time. It's a spin of the wheel.
Grapes! The most important ingredient in crafting wine! Growing your own can be a huge hassle, but there are other options. These options include purchasing grapes either from small growers or local vineyards with leftovers. The goal is to use quality grapes and to be open to variety in order to experiment.
The interaction between the sugar in the grapes and yeast is the main step in creating wine. There are different kinds of yeast to be aware of since some can help create good quality wine while others result in a less desirable product. Another important concept is the environment you provide and length of fermentation time.
With a bit of study of the physicochemical components of wine that are the result of all your efforts, you can predict the success of your product. We used the Vinho Verde red wine dataset, from the north of Portugal, to study those components and how they can be used to make those predictions.
Get familiar with the physicochemical components of wine.
Titratable acidity, sometimes referred to as fixed acidity, is a measurement of the total concentration of titratable acids and free hydrogen ions present in your wine. A litmus paper can be used to identify whether a given solution is acidic or basic. The most common titratable acids are tartaric, malic, citric and carbonic acid. These acids, along with many more in smaller quantities, either occur naturally in the grapes or are created through the fermentation process.
Volatile acidity is mostly caused by bacteria in the wine creating acetic acid — the acid that gives vinegar its characteristic flavor and aroma — and its byproduct, ethyl acetate. Volatile acidity could be an indicator of spoilage, or errors in the manufacturing processes — caused by things like damaged grapes, wine exposed to air, and so on. This causes acetic acid bacteria to enter and thrive, and give rise to unpleasant tastes and smells. Wine experts can often tell this just by smelling it!
Citric acid is generally found in very small quantities in wine grapes. It acts as a preservative and is added to wines to increase acidity, complement a specific flavor or prevent ferric hazes. It can be added to finished wines to increase acidity and give a “fresh” flavor. Excess addition, however, can ruin the taste.
Residual Sugar, or RS for short, refers to any natural grape sugars that are leftover after fermentation ceases (whether on purpose or not). The juice of wine grapes starts out intensely sweet, and fermentation uses up that sugar as the yeasts feast upon it. During winemaking, yeast typically converts all the sugar into alcohol making a dry wine. However, sometimes not all the sugar is fermented by the yeast, leaving some sweetness leftover. To make a wine that tastes good, the key is to have a perfect balance between the sweetness and the sourness in the drink.
The amount of chlorides present in a wine is usually an indicator of its “saltiness.” This is usually influenced by the territory where the wine grapes grew, cultivation methods, and also the grape type. Too much saltiness is considered undesirable. The right proportion can make the wine more savory.
Sulfur dioxide exists in wine in free and bound forms, and the combinations are referred to as total SO2. It’s the most common preservative used, usually added by wine makers to protect the wine from negative effects of exposure to air and oxygen. Wines with added sulphur dioxide contents usually have “Contains Sulphites” on their labels. It acts as a sanitizing agent — adding it usually kills unwanted bacteria or yeast that might enter the wine and spoil its taste and aroma. It was first used in winemaking by the Romans, when they discovered that burning sulfur candles inside empty wine vessels keeps them fresh and free from vinegar smell. Pretty neat, huh?
Also known as specific gravity, it can be used to measure the alcohol concentration in wines. During fermentation, the sugar in the juice is converted into ethanol with carbon dioxide as a waste gas. Monitoring the density during the process allows for optimal control of this conversion step for highest quality wines. Sweeter wines generally have higher densities.
PH is the measure of the degree of relative acidity versus the relative alkalinity of any liquid, on a scale of 0 to 14, with 7 being neutral. Winemakers use pH as a way to measure ripeness in relation to acidity. Low pH wines will taste tart and crisp, while higher pH wines are more susceptible to bacterial growth.
Sulfates are salts of sulfuric acid. They aren’t involved in wine production, but some beer makers use calcium sulfate — also known as brewers’ gypsum — to correct mineral deficiencies in water during the brewing process. It also adds a bit of a “sharp” taste.
Alcohol is formed as a result of yeast converting sugar during the fermentation process.
Gain insight from examining how each component relates to the quality score, and how each component relates to the others.
Use the dropdown to change the charted component.
Correlation Matrix
As we saw in the grid above, components not only affect the quality, but may also relate to one another. Let's take a closer look at some of these relationships.
So how do we help you design a killer wine? It's in the math.
Machine learning is the practice of using statistical algorithms to teach a computer to imitate the way humans process information. We can use it in wine production by teaching the computer to look at how physicochemical components in wine relate to the quality scores given to them by experts in the field.
We trained a lot of different machine learning models on the Vinho Verdi red wine dataset, and we got our best accuracy score from the Random Forests Classifier model. This model is like a really complex flow chart, with many decision trees combined into one. More trees means better predictions. Our model is 95% accurate.
A confusion matrix is a way to visualize the accuracy of your model. Actual quality values are mapped against the quality values predicted by our model. As you can see, our model is pretty darned accurate!
See if you can come up with a quality combination.
Wine Quality Score