Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- structured-data-classification
|
| 4 |
+
dataset:
|
| 5 |
+
- wine-quality
|
| 6 |
+
library_name: scikit-learn
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Wine Quality classification
|
| 10 |
+
|
| 11 |
+
### A Simple Example of Scikit-learn Pipeline
|
| 12 |
+
|
| 13 |
+
> Inspired by https://towardsdatascience.com/a-simple-example-of-pipeline-in-machine-learning-with-scikit-learn-e726ffbb6976
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
### How to use
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from huggingface_hub import hf_hub_url, cached_download
|
| 20 |
+
import joblib
|
| 21 |
+
import pandas as pd
|
| 22 |
+
|
| 23 |
+
REPO_ID = "julien-c/wine-quality"
|
| 24 |
+
FILENAME = "sklearn_model.joblib"
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
model = joblib.load(cached_download(
|
| 28 |
+
hf_hub_url(REPO_ID, FILENAME)
|
| 29 |
+
))
|
| 30 |
+
|
| 31 |
+
# model is a `sklearn.pipeline.Pipeline`
|
| 32 |
+
|
| 33 |
+
data_file = cached_download(
|
| 34 |
+
hf_hub_url(REPO_ID, "winequality-red.csv")
|
| 35 |
+
)
|
| 36 |
+
winedf = pd.read_csv(data_file, sep=";")
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
X = winedf.drop(["quality"], axis=1)
|
| 40 |
+
Y = winedf["quality"]
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
labels = model.predict(X[:3])
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
^^ get your prediction
|
| 47 |
+
|
| 48 |
+
#### Eval
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
model.score(X, Y)
|
| 52 |
+
# 0.6616635397123202
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### 🍷 Disclaimer
|
| 56 |
+
|
| 57 |
+
No red wine was drunk (unfortunately) while training this model 🍷
|
| 58 |
+
|