🍷 "The Hunt for Lord Vinum's Elixir Wine" 🍷¶
Backdrop¶
In the whimsical land of Enchanted Vineyards, legend speaks of an 'Elixir Wine' - a drink concocted by the fabled vintner, Lord Vinum, that allows anyone who drinks it to commune with nature. Amid the vast vineyards, this rare elixir is concealed within bottles of regular wines. Can you distinguish the Elixir Wine from the Regular Wine?
Objective¶
As aspiring wine enthusiasts, your mission is to use the ancient wine scrolls to decipher which of the two varieties conceals the elixir. Sip, savor, and let the data guide you!
Step 1: Unfurl the Ancient Wine Scrolls:
from sklearn import datasets
import pandas as pd
# The age-old Wine Scroll that holds secrets of the wines
wine = datasets.load_wine()
df = pd.DataFrame(wine.data, columns=wine.feature_names)
df['wine_type'] = [0 if i == 0 else 1 for i in wine.target] # 0: Regular Wine, 1: Elixir Wine
df.head()
alcohol | malic_acid | ash | alcalinity_of_ash | magnesium | total_phenols | flavanoids | nonflavanoid_phenols | proanthocyanins | color_intensity | hue | od280/od315_of_diluted_wines | proline | wine_type | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 14.23 | 1.71 | 2.43 | 15.6 | 127.0 | 2.80 | 3.06 | 0.28 | 2.29 | 5.64 | 1.04 | 3.92 | 1065.0 | 0 |
1 | 13.20 | 1.78 | 2.14 | 11.2 | 100.0 | 2.65 | 2.76 | 0.26 | 1.28 | 4.38 | 1.05 | 3.40 | 1050.0 | 0 |
2 | 13.16 | 2.36 | 2.67 | 18.6 | 101.0 | 2.80 | 3.24 | 0.30 | 2.81 | 5.68 | 1.03 | 3.17 | 1185.0 | 0 |
3 | 14.37 | 1.95 | 2.50 | 16.8 | 113.0 | 3.85 | 3.49 | 0.24 | 2.18 | 7.80 | 0.86 | 3.45 | 1480.0 | 0 |
4 | 13.24 | 2.59 | 2.87 | 21.0 | 118.0 | 2.80 | 2.69 | 0.39 | 1.82 | 4.32 | 1.04 | 2.93 | 735.0 | 0 |
Step 2: Prepare the Tasting Session:
Set aside some wines for training and some for tasting and validation.
Practical Tip: Always keep a portion of your wine bottles (data) untouched! The train_test_split
function from scikit-learn is your go-to tool here.
Step 3: Conjure the Wine Diviner:
Use the diviner's mystical energies to predict the elusive Elixir Wine.
LogisticRegression(max_iter=10000)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
LogisticRegression(max_iter=10000)
Practical Tip: Use a LogisticRegression
model from scikit learn
Step 4: Taste & Tell:
Let the diviner predict which wines from your tasting set are the Elixir Wines.
Practical Tip: Your diviner's predictions can be stored in a list or an array, like y_pred.
Step 5: Seek Guidance from the Grapevine:
Validate the diviner's predictions using ancient metrics.
Grapevine's Whispers: Accuracy: 1.00 Precision: 1.00 Recall (Sensitivity): 1.00 Specificity: 1.00
Practical Tip: Use the seaborn
library to visually display the confusion matrix for clearer insights!
Step 6: Grapevineโs Vision: The Enchanted ROC Curve:
Behold the mystical chart that shows the diviner's power to discriminate between Regular and Elixir Wines.
Practical Tip: Adjust the colors and style of the ROC curve to make it even more enchanting!
Quest for Students:
- The grapevine whispers of other ancient methods like the 'Berry Chant' and 'Barrel Rumble' (Decision Trees and SVMs). Try them out!
- Adjust the Wine Diviner's vision by tinkering with probability thresholds. Ensure you donโt misidentify the Elixir Wine, for its taste is said to be...divine!
May your senses be sharp, and the Elixir Wine reveal its secrets to you! ๐๐ท๐พ๐ฎ