Views
No views yet
Inspired by https://towardsdatascience.com/a-simple-example-of-pipeline-in-machine-learning-with-scikit-learn-e726ffbb6976 by Saptashwa Bhattacharyya
1from huggingface_hub import hf_hub_url, cached_download
2import joblib
3import pandas as pd
4
5REPO_ID = "julien-c/wine-quality"
6FILENAME = "sklearn_model.joblib"
7
8
9model = joblib.load(cached_download(
10 hf_hub_url(REPO_ID, FILENAME)
11))
12
13# model is a `sklearn.pipeline.Pipeline`1data_file = cached_download(
2 hf_hub_url(REPO_ID, "winequality-red.csv")
3)
4winedf = pd.read_csv(data_file, sep=";")
5
6
7X = winedf.drop(["quality"], axis=1)
8Y = winedf["quality"]
9
10print(X[:3])| fixed acidity | volatile acidity | citric acid | residual sugar | chlorides | free sulfur dioxide | total sulfur dioxide | density | pH | sulphates | alcohol | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 7.4 | 0.7 | 0 | 1.9 | 0.076 | 11 | 34 | 0.9978 | 3.51 | 0.56 | 9.4 |
| 1 | 7.8 | 0.88 | 0 | 2.6 | 0.098 | 25 | 67 | 0.9968 | 3.2 | 0.68 | 9.8 |
| 2 | 7.8 | 0.76 | 0.04 | 2.3 | 0.092 | 15 | 54 | 0.997 | 3.26 | 0.65 | 9.8 |
1labels = model.predict(X[:3])
2# [5, 5, 5]1model.score(X, Y)
2# 0.6616635397123202