Commit
·
2c46e32
1
Parent(s):
191bbe7
Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- structured-data-classification
|
| 4 |
+
- sklearn
|
| 5 |
+
dataset:
|
| 6 |
+
- wine-quality
|
| 7 |
+
widget:
|
| 8 |
+
structuredData:
|
| 9 |
+
fixed_acidity:
|
| 10 |
+
- 7.4
|
| 11 |
+
- 7.8
|
| 12 |
+
- 10.3
|
| 13 |
+
volatile_acidity:
|
| 14 |
+
- 0.7
|
| 15 |
+
- 0.88
|
| 16 |
+
- 0.32
|
| 17 |
+
citric_acid:
|
| 18 |
+
- 0
|
| 19 |
+
- 0
|
| 20 |
+
- 0.45
|
| 21 |
+
residual_sugar:
|
| 22 |
+
- 1.9
|
| 23 |
+
- 2.6
|
| 24 |
+
- 6.4
|
| 25 |
+
chlorides:
|
| 26 |
+
- 0.076
|
| 27 |
+
- 0.098
|
| 28 |
+
- 0.073
|
| 29 |
+
free_sulfur_dioxide:
|
| 30 |
+
- 11
|
| 31 |
+
- 25
|
| 32 |
+
- 5
|
| 33 |
+
total_sulfur_dioxide:
|
| 34 |
+
- 34
|
| 35 |
+
- 67
|
| 36 |
+
- 13
|
| 37 |
+
density:
|
| 38 |
+
- 0.9978
|
| 39 |
+
- 0.9968
|
| 40 |
+
- 0.9976
|
| 41 |
+
pH:
|
| 42 |
+
- 3.51
|
| 43 |
+
- 3.2
|
| 44 |
+
- 3.23
|
| 45 |
+
sulphates:
|
| 46 |
+
- 0.56
|
| 47 |
+
- 0.68
|
| 48 |
+
- 0.82
|
| 49 |
+
alcohol:
|
| 50 |
+
- 9.4
|
| 51 |
+
- 9.8
|
| 52 |
+
- 12.6
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## Wine Quality classification
|
| 56 |
+
|
| 57 |
+
### A Simple Example of Scikit-learn Pipeline
|
| 58 |
+
|
| 59 |
+
> Inspired by https://towardsdatascience.com/a-simple-example-of-pipeline-in-machine-learning-with-scikit-learn-e726ffbb6976 by Saptashwa Bhattacharyya
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
### How to use
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
from huggingface_hub import hf_hub_url, cached_download
|
| 66 |
+
import joblib
|
| 67 |
+
import pandas as pd
|
| 68 |
+
|
| 69 |
+
REPO_ID = "julien-c/wine-quality"
|
| 70 |
+
FILENAME = "sklearn_model.joblib"
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
model = joblib.load(cached_download(
|
| 74 |
+
hf_hub_url(REPO_ID, FILENAME)
|
| 75 |
+
))
|
| 76 |
+
|
| 77 |
+
# model is a `sklearn.pipeline.Pipeline`
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
#### Get sample data from this repo
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
data_file = cached_download(
|
| 84 |
+
hf_hub_url(REPO_ID, "winequality-red.csv")
|
| 85 |
+
)
|
| 86 |
+
winedf = pd.read_csv(data_file, sep=";")
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
X = winedf.drop(["quality"], axis=1)
|
| 90 |
+
Y = winedf["quality"]
|
| 91 |
+
|
| 92 |
+
print(X[:3])
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
| | fixed acidity | volatile acidity | citric acid | residual sugar | chlorides | free sulfur dioxide | total sulfur dioxide | density | pH | sulphates | alcohol |
|
| 96 |
+
|---:|----------------:|-------------------:|--------------:|-----------------:|------------:|----------------------:|-----------------------:|----------:|-----:|------------:|----------:|
|
| 97 |
+
| 0 | 7.4 | 0.7 | 0 | 1.9 | 0.076 | 11 | 34 | 0.9978 | 3.51 | 0.56 | 9.4 |
|
| 98 |
+
| 1 | 7.8 | 0.88 | 0 | 2.6 | 0.098 | 25 | 67 | 0.9968 | 3.2 | 0.68 | 9.8 |
|
| 99 |
+
| 2 | 7.8 | 0.76 | 0.04 | 2.3 | 0.092 | 15 | 54 | 0.997 | 3.26 | 0.65 | 9.8 |
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
#### Get your prediction
|
| 103 |
+
|
| 104 |
+
```python
|
| 105 |
+
labels = model.predict(X[:3])
|
| 106 |
+
# [5, 5, 5]
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
#### Eval
|
| 110 |
+
|
| 111 |
+
```python
|
| 112 |
+
model.score(X, Y)
|
| 113 |
+
# 0.6616635397123202
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
### 🍷 Disclaimer
|
| 117 |
+
|
| 118 |
+
No red wine was drunk (unfortunately) while training this model 🍷
|
| 119 |
+
|