1import pickle
2import numpy as np
3from huggingface_hub import hf_hub_download
4
5# Download and load model
6model_path = hf_hub_download("victor/wine-type-classifier", "model.pkl")
7with open(model_path, "rb") as f:
8 model = pickle.load(f)
9
10# Labels: 0 = Red Wine, 1 = White Wine
11labels = {0: "Red Wine", 1: "White Wine"}
12
13# Input features (in order):
14# fixed_acidity, volatile_acidity, citric_acid, residual_sugar,
15# chlorides, free_sulfur_dioxide, total_sulfur_dioxide,
16# density, pH, sulphates, alcohol, quality
17
18# Example: predict a red wine
19sample = np.array([[7.4, 0.7, 0.0, 1.9, 0.076, 11.0, 34.0, 0.9978, 3.51, 0.56, 9.4, 5]])
20prediction = model.predict(sample)[0]
21probabilities = model.predict_proba(sample)[0]
22
23print(f"Prediction: {labels[prediction]}")
24print(f"Confidence: {max(probabilities):.2%}")
1pip install scikit-learn datasets huggingface_hub
2python train_wine.py